forked from yabwe/medium-editor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresize.spec.js
45 lines (39 loc) · 1.61 KB
/
resize.spec.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
/*global MediumEditor, describe, it, expect,
afterEach, beforeEach, fireEvent, spyOn,
selectElementContents, jasmine, tearDown,
console, xit*/
describe('Resize TestCase', function () {
'use strict';
beforeEach(function () {
jasmine.clock().install();
this.el = document.createElement('div');
this.el.className = 'editor';
this.el.innerHTML = 'test content';
document.body.appendChild(this.el);
});
afterEach(function () {
tearDown(this.el);
jasmine.clock().uninstall();
});
it('should reset toolbar position on window resize', function () {
var editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
jasmine.clock().tick(101);
expect(editor.toolbar.className.indexOf('active') > -1).toBe(true);
spyOn(editor, 'setToolbarPosition');
fireEvent(window, 'resize');
jasmine.clock().tick(101);
expect(editor.setToolbarPosition).toHaveBeenCalled();
});
// I believe some other test is breaking this one, it passes when runs alone
// it is calling setToolbar even with no text selected
xit('should not call setToolbarPosition when toolbar is not visible', function () {
var editor = new MediumEditor('.editor');
spyOn(editor, 'setToolbarPosition');
fireEvent(window, 'resize');
jasmine.clock().tick(101);
expect(editor.toolbar.className.indexOf('active')).toBe(-1);
expect(editor.setToolbarPosition).not.toHaveBeenCalled();
});
});