mirror of
https://github.com/fengyuanchen/viewerjs.git
synced 2025-12-08 19:56:00 +00:00
40 lines
964 B
JavaScript
40 lines
964 B
JavaScript
describe('toggle (method)', () => {
|
|
it('should toggle the scale of the current viewing image between its current ratio and 1', (done) => {
|
|
const image = window.createImage();
|
|
const viewer = new Viewer(image, {
|
|
viewed() {
|
|
const { imageData } = viewer;
|
|
const { ratio } = imageData;
|
|
|
|
viewer.toggle();
|
|
expect(imageData.ratio).to.equal(1);
|
|
viewer.toggle();
|
|
expect(imageData.ratio).to.equal(ratio);
|
|
viewer.hide(true);
|
|
done();
|
|
},
|
|
});
|
|
|
|
viewer.show();
|
|
});
|
|
|
|
it('should not work when it is not zoomable', (done) => {
|
|
const image = window.createImage();
|
|
const viewer = new Viewer(image, {
|
|
zoomable: false,
|
|
|
|
viewed() {
|
|
const { imageData } = viewer;
|
|
const { ratio } = imageData;
|
|
|
|
viewer.toggle();
|
|
expect(imageData.ratio).to.equal(ratio);
|
|
viewer.hide(true);
|
|
done();
|
|
},
|
|
});
|
|
|
|
viewer.show();
|
|
});
|
|
});
|