-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathInsertOpDenormalizer.test.ts
34 lines (28 loc) · 1.14 KB
/
InsertOpDenormalizer.test.ts
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
import 'mocha';
import * as assert from 'assert';
import { InsertOpDenormalizer } from './../src/InsertOpDenormalizer';
describe('InsertOpDenormalizer', function () {
describe('#denormalize()', function () {
it('should return denormalized op as array of ops', function () {
var op = { insert: '\n' };
var act = InsertOpDenormalizer.denormalize({ insert: '\n' });
assert.deepEqual(act, [op]);
op = { insert: 'abc' };
act = InsertOpDenormalizer.denormalize(op);
assert.deepEqual(act, [op]);
var op2 = { insert: 'abc\n', attributes: { link: 'cold' } };
act = InsertOpDenormalizer.denormalize(op2);
assert.equal(act.length, 2);
assert.equal(act[0].insert, 'abc');
assert.equal(act[0].attributes.link, 'cold');
var op3 = { insert: '\n\n', attributes: { bold: true } };
act = InsertOpDenormalizer.denormalize(op3);
assert.equal(act.length, 2);
assert.equal(act[1].insert, '\n');
act = InsertOpDenormalizer.denormalize(null);
assert.deepEqual(act, []);
act = InsertOpDenormalizer.denormalize('..');
assert.deepEqual(act, []);
});
});
});