blob: 58905f7656701878c67977ab19768cb1b2146cac [file] [log] [blame]
<!--
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta charset="utf-8">
<title>image-diff-tool</title>
<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>
<script src="../node_modules/resemblejs/resemble.js"></script>
<test-fixture id="basicFixture">
<template>
<gr-image-diff-tool>
</gr-image-diff-tool>
</template>
</test-fixture>
<script type="module">
import '../test/common-test-setup.js';
import "./gr-image-diff-tool.js";
suite('gr-image-diff-tool tests', () => {
let element;
let sandbox;
setup(() => {
sandbox = sinon.sandbox.create();
element = fixture('basicFixture');
flushAsynchronousOperations();
});
teardown(() => { sandbox.restore(); });
test('test opacity mode', () => {
element._observeMode = 'opacity';
assert.isTrue(element._showOpacityMode);
assert.isFalse(element._showResembleMode);
flushAsynchronousOperations();
assert.ok(element.shadowRoot.querySelector('gr-opacity-diff-mode'));
assert.equal(element.shadowRoot.querySelector('gr-resemble-diff-mode'), null);
});
test('test resemble mode', () => {
element._observeMode = 'resemble';
assert.isTrue(element._showResembleMode);
assert.isFalse(element._showOpacityMode);
flushAsynchronousOperations();
assert.ok(element.shadowRoot.querySelector('gr-resemble-diff-mode'));
assert.equal(element.shadowRoot.querySelector('gr-opacity-diff-mode'), null);
});
test('localStorage persists', () => {
sandbox.stub(element, '_setMode');
sandbox.stub(element, '_getMode');
element.connectedCallback();
assert.equal(element._getMode.callCount, 1);
assert.equal(element._setMode.callCount, 1);
element._observeMode = 'opacity';
assert.equal(element._setMode.callCount, 2);
element._observeMode = 'resemble';
assert.equal(element._setMode.callCount, 3);
});
});
</script>