Refactor to use mapping of item to index instead of harcoding index
Change-Id: Id742dc66c48c4f49d158621d16f0fd3e14e956b3
diff --git a/gr-checks/gr-checks-item_test.html b/gr-checks/gr-checks-item_test.html
index 6e21b1f..bccfe9c 100644
--- a/gr-checks/gr-checks-item_test.html
+++ b/gr-checks/gr-checks-item_test.html
@@ -19,6 +19,17 @@
</test-fixture>
<script>
+ const CHECKS_ITEM = {
+ MESSAGE: 1,
+ NAME: 2,
+ BLOCKING: 3,
+ STATUS: 4,
+ START_TIME: 5,
+ DURATION: 6,
+ DETAILS: 7,
+ RERUN: 8,
+ DESCRIPTION: 9,
+ };
suite('gr-checks-item tests', async () => {
await readyToTest();
let element;
@@ -45,7 +56,8 @@
teardown(() => { sandbox.restore(); });
test('renders the status', () => {
- const status = element.$$('td:nth-child(4) > gr-checks-status');
+ const idx = CHECKS_ITEM.STATUS;
+ const status = element.$$(`td:nth-child(${idx}) > gr-checks-status`);
assert.exists(status);
});
@@ -55,7 +67,8 @@
suite('duration', () => {
test('renders the run duration', () => {
- const name = element.$$('td:nth-child(6)');
+ const idx = CHECKS_ITEM.DURATION;
+ const name = element.$$(`td:nth-child(${idx})`);
assert.equal(name .textContent.trim(), '25 sec');
});
@@ -66,13 +79,15 @@
started: '2019-02-06T22:25:19.269Z',
finished: '2019-02-06T22:25:19.269Z',
};
- const name = element.$$('td:nth-child(6)');
+ const idx = CHECKS_ITEM.DURATION;
+ const name = element.$$(`td:nth-child(${idx})`);
assert.equal(name .textContent.trim(), '0 sec');
});
});
test('renders a link to the log', () => {
- const logLink = element.$$('td:nth-child(7) > a');
+ const idx = CHECKS_ITEM.DETAILS;
+ const logLink = element.$$(`td:nth-child(${idx}) > a`);
assert.equal(logLink.getAttribute('href'),
'http://example.com/test-log-url');
assert.equal(logLink.textContent.trim(), 'Details');