| <!DOCTYPE html> |
| <!-- |
| Copyright 2020 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
| <script src="../bower_components/webcomponentsjs/webcomponents-lite.js"></script> |
| <script src="../bower_components/web-component-tester/browser.js"></script> |
| |
| <title>coverage percentage views test</title> |
| |
| <test-fixture id="absolute-header-view"> |
| <template> |
| <absolute-header-view></absolute-header-view> |
| </template> |
| </test-fixture> |
| |
| <test-fixture id="incremental-header-view"> |
| <template> |
| <incremental-header-view></incremental-header-view> |
| </template> |
| </test-fixture> |
| |
| <test-fixture id="absolute-content-view"> |
| <template> |
| <absolute-content-view></absolute-content-view> |
| </template> |
| </test-fixture> |
| |
| <test-fixture id="incremental-content-view"> |
| <template> |
| <incremental-content-view></incremental-content-view> |
| </template> |
| </test-fixture> |
| |
| <script type="module"> |
| import './common-test-setup.js'; |
| import '../src/main/resources/static/coverage-percentage-views.js'; |
| |
| suite('<coverage percentage views>', () => { |
| test('absolute header view', () => { |
| const element = fixture('absolute-header-view'); |
| assert.equal(element.shadowRoot.querySelector('div').textContent.trim(), '|Cov.|'); |
| }); |
| |
| test('incremental header view', () => { |
| const element = fixture('incremental-header-view'); |
| assert.equal(element.shadowRoot.querySelector('div').textContent.trim(), 'ΔCov.'); |
| }); |
| |
| test('absolute content view', (done) => { |
| const element = fixture('absolute-content-view'); |
| element.changeNum = '12345'; |
| element.patchRange = {patchNum: '2'}; |
| element.path = 'base/test.cc'; |
| element.provider = (changeNum, path, patchNum) => { |
| return { |
| absolute: 30, |
| incremental: 75, |
| }; |
| }; |
| |
| flush(() => { |
| assert.equal(element.percentageText, '30%'); |
| done(); |
| }); |
| }); |
| |
| test('absolute content view percentages are not available', (done) => { |
| const element = fixture('absolute-content-view'); |
| element.changeNum = '12345'; |
| element.patchRange = {patchNum: '2'}; |
| element.path = 'base/test.cc'; |
| element.provider = (changeNum, path, patchNum) => { |
| return null; |
| }; |
| |
| flush(() => { |
| assert.equal(element.percentageText, '-'); |
| done(); |
| }); |
| }); |
| |
| test('incremental content view', (done) => { |
| const element = fixture('incremental-content-view'); |
| element.changeNum = '12345'; |
| element.patchRange = {patchNum: '2'}; |
| element.path = 'base/test.cc'; |
| element.provider = (changeNum, path, patchNum) => { |
| return { |
| absolute: 30, |
| incremental: 75, |
| }; |
| }; |
| |
| flush(() => { |
| assert.equal(element.percentageText, '75%'); |
| done(); |
| }); |
| }); |
| |
| test('incremental content view percentages are not available', (done) => { |
| const element = fixture('incremental-content-view'); |
| element.changeNum = '12345'; |
| element.patchRange = {patchNum: '2'}; |
| element.path = 'base/test.cc'; |
| element.provider = (changeNum, path, patchNum) => { |
| return null; |
| }; |
| |
| flush(() => { |
| assert.equal(element.percentageText, '-'); |
| done(); |
| }); |
| }); |
| |
| test('incremental content view incremenal percentage is not available', |
| (done) => { |
| const element = fixture('incremental-content-view'); |
| element.changeNum = '12345'; |
| element.patchRange = {patchNum: '2'}; |
| element.path = 'base/test.cc'; |
| element.provider = (changeNum, path, patchNum) => { |
| return { |
| absolute: 30, |
| incremental: null, |
| }; |
| }; |
| |
| flush(() => { |
| assert.equal(element.percentageText, '-'); |
| done(); |
| }); |
| }); |
| }); |
| </script> |