viewerjs/test/specs/methods/move.spec.js
2018-02-13 21:52:05 +08:00

40 lines
1022 B
JavaScript

describe('move (method)', () => {
it('should move with the given offsets', (done) => {
const image = window.createImage();
const viewer = new Viewer(image, {
inline: true,
viewed() {
const { imageData } = viewer;
const { left, top } = imageData;
viewer.move(10, 10);
expect(imageData.left).to.equal(left + 10);
expect(imageData.top).to.equal(top + 10);
viewer.move(-10, -10);
expect(imageData.left).to.equal(left);
expect(imageData.top).to.equal(top);
done();
},
});
});
it('should not work when it is not movable', (done) => {
const image = window.createImage();
const viewer = new Viewer(image, {
inline: true,
movable: false,
viewed() {
const { imageData } = viewer;
const { left, top } = imageData;
viewer.move(10, 10);
expect(imageData.left).to.equal(left);
expect(imageData.top).to.equal(top);
done();
},
});
});
});