Skip to content

Commit

Permalink
fix: wip: test: convert haunted-pan-zoom and detach tests to karma
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Kullman <[email protected]>
  • Loading branch information
Patrik Kullman authored and megheaiulian committed Jun 17, 2020
1 parent fb59316 commit 380e75b
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 305 deletions.
109 changes: 0 additions & 109 deletions test/detach.html

This file was deleted.

77 changes: 77 additions & 0 deletions test/detach.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@


import '../cosmoz-image-viewer.js';
import {
assert, fixture, html
} from '@open-wc/testing';

import sinon from 'sinon';

sinon.assert.expose(chai.assert, { prefix: '' });

const createImageViewer = async () => {
const el = await fixture(html`<cosmoz-image-viewer show-zoom></cosmoz-image-viewer>`);

el.images = [
'/base/stories/images/stockholm.jpg',
'/base/stories/images/strasbourg.jpg',
'/base/stories/images/cosmos1.jpg'
];

return el;
};

suite('cosmoz-image-viewer', () => {
let imageViewer;

setup(async function () {
imageViewer = await createImageViewer();

const w = imageViewer.detach();
if (w == null) {
/* eslint-disable-next-line no-console */
console.warn('Only gets tested without popup blocker');
/* eslint-disable-next-line no-invalid-this */
this.skip();
}
w.close();
});

teardown(() => {
imageViewer.window.close();
});

test('detaching works', () => {
const w = imageViewer.detach();
assert.isNotNull(w);
});

test('detaching to existing window works', () => {
const w = imageViewer.detach(),
w2 = imageViewer.detach();
assert.isNotNull(w);
assert.deepEqual(w, w2);
});

test('shared detaching works', async () => {
const imageViewer2 = await createImageViewer(),
w = imageViewer.detach(),
w2 = imageViewer2.detach();
assert.isNotNull(w);
assert.deepEqual(w, w2);
});

test('detach from fullscreen works', () => {
assert.isFalse(imageViewer.hidden);
assert.isFalse(imageViewer.hasWindow);

imageViewer.openFullscreen();
assert.isFalse(imageViewer.hasWindow);

const ov = document.querySelector('cosmoz-image-viewer-overlay');

ov.shadowRoot.querySelector('cosmoz-image-viewer').detach();
assert.isTrue(imageViewer.hasWindow);
assert.isTrue(imageViewer.hidden);
});
});
152 changes: 0 additions & 152 deletions test/haunted-pan-zoom.html

This file was deleted.

Loading

0 comments on commit 380e75b

Please sign in to comment.