| <!DOCTYPE html> |
| <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
| <script src="imports.js"></script> |
| <script src="webcomponentsjs/webcomponents-lite.js"></script> |
| <link rel="import" href="polymer/polymer.html"> |
| |
| <title>builds-chip-view</title> |
| <link rel="import" href="webcomponent_lib/builds-chip-view.html"> |
| |
| <test-fixture id="basic"> |
| <template is="dom-template"> |
| <builds-chip-view change="[[change]]" revision="[[revision]]" get-build-results="[[getBuildResults]]"></builds-chip-view> |
| </template> |
| </test-fixture> |
| |
| <script> |
| const BUILD1 = { |
| buildTriggerId: 'test-build-trigger-id', |
| logUrl: 'http://example.com/test-log-url', |
| startTime: "2019-02-06T22:25:19.269Z", |
| finishTime: "2019-02-06T22:25:44.574Z", |
| status: 'SUCCESS', |
| }; |
| |
| const BUILD2 = { |
| buildTriggerId: 'test-build-trigger-id-2', |
| logUrl: 'http://example.com/test-log-url', |
| startTime: "2019-02-06T22:25:19.269Z", |
| finishTime: "2019-02-06T22:25:44.574Z", |
| status: 'FAILURE', |
| }; |
| |
| suite('build-chip-view tests', () => { |
| let element; |
| let sandbox; |
| let getBuildResultsSpy; |
| |
| setup((done) => { |
| sandbox = sinon.sandbox.create(); |
| |
| getBuildResultsSpy = sinon.stub(); |
| getBuildResultsSpy.returns(Promise.resolve([BUILD1, BUILD2, BUILD1])); |
| |
| element = fixture('basic', { |
| getBuildResults: getBuildResultsSpy, |
| change: { |
| 'project': 'test-repository', |
| 'revisions': { |
| 'first-sha': "test-revision", |
| 'second-sha': "test-revision2", |
| } |
| }, |
| revision: 'test-revision2', |
| }); |
| flush(done); |
| }); |
| |
| teardown(() => { sandbox.restore(); }); |
| |
| test('renders the checks prefix', () => { |
| assert.include(element.textContent.trim(), 'Checks:'); |
| }); |
| |
| suite('builds chip contents', () => { |
| test('queries the builds', () => { |
| assert.isTrue(getBuildResultsSpy.called); |
| assert.isTrue(getBuildResultsSpy.calledWith('test-repository', 'second-sha')); |
| }); |
| |
| test('renders the text of failed builds', () => { |
| const chip = element.$$('.chip'); |
| assert.equal(chip.textContent.trim(), '1 of 3 builds failed'); |
| }); |
| }); |
| }); |
| </script> |