| <!DOCTYPE html> |
| <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
| <script src="/node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script> |
| <script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> |
| <script src="../bower_components/web-component-tester/browser.js"></script> |
| |
| <title>gr-checks-chip-view</title> |
| |
| <test-fixture id="basic"> |
| <template> |
| <gr-checks-chip-view></gr-checks-chip-view> |
| </template> |
| </test-fixture> |
| |
| <script type="module"> |
| import '../test/common-test-setup.js'; |
| import './gr-checks-chip-view.js'; |
| const CHECK1 = { |
| checkId: 'test-check-id', |
| log: 'http://example.com/test-log-url', |
| started: '2019-02-06T22:25:19.269Z', |
| finished: '2019-02-06T22:25:44.574Z', |
| state: 'SUCCESSFUL', |
| }; |
| |
| const CHECK2 = { |
| checkId: 'test-check-id-2', |
| log: 'http://example.com/test-log-url', |
| started: '2019-02-06T22:25:19.269Z', |
| finished: '2019-02-06T22:25:44.574Z', |
| state: 'FAILED', |
| }; |
| |
| suite('gr-checks-chip-view tests', () => { |
| let element; |
| let sandbox; |
| let getChecksSpy; |
| |
| setup(done => { |
| sandbox = sinon.sandbox.create(); |
| |
| getChecksSpy = sinon.stub(); |
| getChecksSpy.returns(Promise.resolve([CHECK1, CHECK2, CHECK1])); |
| |
| element = fixture('basic'); |
| element.getChecks = getChecksSpy; |
| element.change = { |
| _number: 314, |
| current_revision: 'abcd', |
| revisions: { |
| abcd: { |
| _number: 271, |
| }, |
| }, |
| }; |
| element.revision = { |
| _number: 271, |
| }; |
| flush(done); |
| }); |
| |
| teardown(() => { sandbox.restore(); }); |
| |
| test('renders the checks prefix', () => { |
| assert.include(element.shadowRoot.textContent.trim(), 'Checks:'); |
| }); |
| |
| test('updating revision does not update getChecks call', done => { |
| element.revision = {_number: 272}; |
| flush(() => { |
| assert.isFalse(getChecksSpy.calledWith(314, 272)); |
| done(); |
| }); |
| }); |
| |
| suite('builds chip contents', () => { |
| test('queries the checks', () => { |
| assert.isTrue(getChecksSpy.called); |
| assert.isTrue(getChecksSpy.calledWith(314, 271)); |
| }); |
| |
| test('renders the text of failed checks', () => { |
| const chip = element.$$('.chip'); |
| assert.equal(chip.textContent.trim(), '1 of 3 checks failed'); |
| }); |
| }); |
| }); |
| </script> |