-
Notifications
You must be signed in to change notification settings - Fork 110
/
tinymceSpec.js
49 lines (43 loc) · 1.91 KB
/
tinymceSpec.js
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
import { Tinymce } from '../utils/tinymce';
beforeEach(() => {
$('body').append('<textarea class="test" id="test1"></textarea>');
$('body').append('<textarea class="test" id="test2"></textarea>');
Tinymce.init({ selector: '.test' });
});
describe('findEditorsByClassName test suite', () => {
it('expect two editors with class name test', () => expect(Tinymce.findEditorsByClassName('test').length).toBe(2));
it('expect zero editors with class name whatever', () => expect(Tinymce.findEditorsByClassName('whatever').length).toBe(0));
});
describe('findEditorById test suite', () => {
it('expect editor with id test1 to be defined', () => expect(Tinymce.findEditorById('test1')).toBeDefined());
it('expect editor with id test2 to be defined', () => expect(Tinymce.findEditorById('test2')).toBeDefined());
it('expect editor with id whatever to be undefined', () => expect(Tinymce.findEditorById('whatever')).not.toBeDefined());
});
describe('destroyEditorsByClassName test suite', () => {
it('expect remaining two editors', () => {
Tinymce.destroyEditorsByClassName('whatever');
expect(Tinymce.findEditorsByClassName('test').length).toBe(2);
});
it('expect remaining zero editors', () => {
Tinymce.destroyEditorsByClassName('test');
expect(Tinymce.findEditorsByClassName('test').length).toBe(0);
});
});
describe('destroyEditorsById test suite', () => {
it('expect remaining two editors', () => {
Tinymce.destroyEditorById('test3');
expect(Tinymce.findEditorsByClassName('test').length).toBe(2);
});
it('expect remaining one editor', () => {
Tinymce.destroyEditorById('test1');
expect(Tinymce.findEditorsByClassName('test').length).toBe(1);
});
it('expect remaining zero editors', () => {
Tinymce.destroyEditorById('test1');
Tinymce.destroyEditorById('test2');
expect(Tinymce.findEditorsByClassName('test').length).toBe(0);
});
});
afterEach(() => {
$('body').html('');
});