| <!DOCTYPE html> |
| <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
| <script src="../../../bower_components/webcomponentsjs/webcomponents.js"></script> |
| <script src="/bower_components/web-component-tester/browser.js"></script> |
| <script src="../../../bower_components/moment/min/moment.min.js"></script> |
| <link rel="import" href="/bower_components/polymer/polymer.html"> |
| |
| <title>gr-checks-item</title> |
| <link rel="import" href="gr-checks-item.html"> |
| |
| <test-fixture id="basic"> |
| <template is="dom-template"> |
| <gr-checks-item |
| check="{{check}}" |
| retry-check="[[retryCheck]]"> |
| </gr-checks-item> |
| </template> |
| </test-fixture> |
| |
| <script> |
| suite('gr-checks-item tests', () => { |
| let element; |
| let sandbox; |
| let retryCheckSpy; |
| |
| setup((done) => { |
| sandbox = sinon.sandbox.create(); |
| retryCheckSpy = sinon.stub(); |
| retryCheckSpy.returns(Promise.resolve()); |
| |
| element = fixture('basic', { |
| retryCheck: retryCheckSpy, |
| check: { |
| checkId: 'test-check-id', |
| url: 'http://example.com/test-log-url', |
| started: "2019-02-06T22:25:19.269Z", |
| finished: "2019-02-06T22:25:44.574Z", |
| }, |
| }); |
| flush(done); |
| }); |
| |
| teardown(() => { sandbox.restore(); }); |
| |
| test('renders the status', () => { |
| const status = element.$$('td:nth-child(4) > gr-checks-status'); |
| assert.exists(status); |
| }); |
| |
| test('renders the run time', () => { |
| const name = element.$$('td:nth-child(6)'); |
| assert.equal(name .textContent.trim(), "11:25:19 PM"); |
| }); |
| |
| suite('duration', () => { |
| test('renders the run duration', () => { |
| const name = element.$$('td:nth-child(7)'); |
| assert.equal(name .textContent.trim(), "25 sec"); |
| }); |
| |
| test('renders 0 sec when the start and end time are the same', () => { |
| element.check = { |
| checkId: 'test-check-id', |
| url: 'http://example.com/test-log-url', |
| started: "2019-02-06T22:25:19.269Z", |
| finished: "2019-02-06T22:25:19.269Z", |
| }; |
| const name = element.$$('td:nth-child(7)'); |
| assert.equal(name .textContent.trim(), "0 sec"); |
| }); |
| }); |
| |
| test('renders a link to the log', () => { |
| const logLink = element.$$('td:nth-child(8) > a'); |
| assert.equal(logLink.getAttribute('href'), "http://example.com/test-log-url"); |
| assert.equal(logLink.textContent.trim(), "View log"); |
| }); |
| |
| // pausing this check until retry api is available from backend |
| // suite('retryCheck', () => { |
| // let retryCheckLink; |
| |
| // setup(() => { |
| // retryCheckLink = element.$$('td:nth-child(7) > gr-button'); |
| // }); |
| |
| // test('shows a link to the retry button', () => { |
| // assert.equal(retryCheckLink.textContent.trim(), "Re-run"); |
| // }); |
| |
| // test('clicking on the link calls the retryCheck property', () => { |
| // assert.isFalse(retryCheckSpy.called); |
| // retryCheckLink.click(); |
| // assert.isTrue(retryCheckSpy.called); |
| // }); |
| // }); |
| |
| }); |
| </script> |