blob: 6e21b1fceed8fd8d0a89690fbc1768626a1f9e28 [file] [log] [blame]
<!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-lite.min.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">
<script src="test-pre-setup.js"></script>
<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', async () => {
await readyToTest();
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 start time', () => {
assert.equal(element._startTime, '2019-02-06T22:25:19.269Z');
});
suite('duration', () => {
test('renders the run duration', () => {
const name = element.$$('td:nth-child(6)');
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(6)');
assert.equal(name .textContent.trim(), '0 sec');
});
});
test('renders a link to the log', () => {
const logLink = element.$$('td:nth-child(7) > a');
assert.equal(logLink.getAttribute('href'),
'http://example.com/test-log-url');
assert.equal(logLink.textContent.trim(), 'Details');
});
});
</script>