blob: 3963dc456a2e4bac6502094903010c41e0cb9bc6 [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="/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-item</title>
<test-fixture id="basic">
<template>
<gr-checks-status></gr-checks-status>
</template>
</test-fixture>
<script type="module">
import '../test/common-test-setup.js';
import './gr-checks-status.js';
suite('gr-checks-status tests', () => {
let sandbox;
setup(() => {
sandbox = sinon.sandbox.create();
});
teardown(() => { sandbox.restore(); });
function testStatus(expectedStatusClass, statusText, statusesToTest) {
suite(expectedStatusClass, () => {
for (const statusToTest of statusesToTest) {
test(`renders ${expectedStatusClass} for ${statusToTest}`, done => {
const element = fixture('basic');
element.status = statusToTest;
element.showText = false;
flush(() => {
const svg = element.shadowRoot.querySelector(`span svg`);
assert.isOk(svg);
done();
});
});
test(`renders ${expectedStatusClass} for ${statusToTest} rendering
text ${statusText}`, done => {
const element = fixture('basic');
element.status = statusToTest;
element.showText = true;
flush(() => {
const text = element.shadowRoot.querySelector(`span span`);
assert.equal(text.textContent.trim(), statusText);
done();
});
});
}
});
}
testStatus('successful', 'Successful', ['SUCCESSFUL']);
testStatus('failed', 'Failed', ['FAILED']);
testStatus('running', 'Running', ['RUNNING']);
testStatus('running', 'Scheduled', ['SCHEDULED']);
testStatus('unevaluated', 'Unevaluated', ['NOT_STARTED']);
});
</script>