filter.spec.js
1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* @author NHN Ent. FE Development Team <dl_javascript@nhn.com>
* @fileoverview Test cases of "src/js/component/filter.js"
*/
import ImageEditor from '../src/js/imageEditor';
describe('Filter', () => {
let imageEditor;
const imageURL = 'base/test/fixtures/sampleImage.jpg';
beforeEach((done) => {
imageEditor = new ImageEditor(document.createElement('div'), {
cssMaxWidth: 700,
cssMaxHeight: 500,
});
imageEditor.loadImageFromURL(imageURL, 'sampleImage').then(() => {
imageEditor.clearUndoStack();
done();
});
});
afterEach(() => {
imageEditor.destroy();
});
it('applyFilter() can add undo stack', (done) => {
imageEditor
.applyFilter('colorFilter')
.then(() => {
expect(imageEditor.isEmptyUndoStack()).toBe(false);
done();
})
['catch'](() => {
fail();
done();
});
});
it('applyFilter() can not add undo stack at isSilent', (done) => {
const isSilent = true;
imageEditor
.applyFilter('colorFilter', {}, isSilent)
.then(() => {
expect(imageEditor.isEmptyUndoStack()).toBe(true);
done();
})
['catch'](() => {
fail();
done();
});
});
it('hasFilter', () => {
imageEditor.applyFilter('colorFilter');
expect(imageEditor.hasFilter('invert')).toBe(false);
expect(imageEditor.hasFilter('colorFilter')).toBe(true);
});
it('removeFilter() can remove added filter', (done) => {
imageEditor
.applyFilter('colorFilter')
.then(() => imageEditor.removeFilter('colorFilter'))
.then(() => {
expect(imageEditor.hasFilter('colorFilter')).toBe(false);
expect(imageEditor.isEmptyUndoStack()).toBe(false);
done();
})
['catch'](() => {
fail();
done();
});
});
});