-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: wip: test: convert haunted-pan-zoom and detach tests to karma
Signed-off-by: Patrik Kullman <[email protected]>
- Loading branch information
1 parent
fb59316
commit 380e75b
Showing
7 changed files
with
202 additions
and
305 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.