forked from yabwe/medium-editor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserialize.spec.js
41 lines (35 loc) · 1.21 KB
/
serialize.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
/*global MediumEditor, describe, it, expect, spyOn,
afterEach, beforeEach, selectElementContents,
fireEvent, tearDown*/
describe('Anchor Button TestCase', function () {
'use strict';
beforeEach(function () {
this.el = document.createElement('div');
this.el.className = 'editor';
this.el.id = 'medium-editor-test';
this.el.innerHTML = '<p>lorem <strong>ipsum</strong></p>';
document.body.appendChild(this.el);
});
afterEach(function () {
tearDown(this.el);
});
it('should return the editor content as a JSON object', function () {
var editor = new MediumEditor('.editor'),
json = editor.serialize();
expect(json).toEqual({
'medium-editor-test': {
value: '<p>lorem <strong>ipsum</strong></p>'
}
});
});
it('should set a custom id when elements have no ids', function () {
this.el.removeAttribute('id');
var editor = new MediumEditor('.editor'),
json = editor.serialize();
expect(json).toEqual({
'element-0': {
value: '<p>lorem <strong>ipsum</strong></p>'
}
});
});
});