forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mimemodel.spec.ts
109 lines (79 loc) · 2.31 KB
/
mimemodel.spec.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import expect = require('expect.js');
import {
JSONExt
} from '@phosphor/coreutils';
import {
MimeModel
} from '@jupyterlab/rendermime';
describe('rendermime/mimemodel', () => {
let model: MimeModel;
beforeEach(() => {
model = new MimeModel();
});
afterEach(() => {
model.dispose();
});
describe('MimeModel', () => {
describe('#constructor()', () => {
it('should create a new mime model', () => {
let model = new MimeModel();
expect(model).to.be.a(MimeModel);
});
it('should accept arguments', () => {
let model = new MimeModel({
data: { 'foo': 1},
trusted: true,
metadata: { 'bar': 'baz' }
});
expect(model).to.be.a(MimeModel);
});
});
describe('#trusted', () => {
it('should get the trusted state of the model', () => {
let model = new MimeModel();
expect(model.trusted).to.be(false);
model = new MimeModel({ trusted: true });
expect(model.trusted).to.be(true);
});
});
describe('#dispose()', () => {
it('should dispose of the resources used by the model', () => {
let model = new MimeModel();
model.dispose();
expect(model.isDisposed).to.be(true);
model.dispose();
expect(model.isDisposed).to.be(true);
});
});
describe('#data', () => {
it('should be the data observable map', () => {
let model = new MimeModel({
data: { 'bar': 'baz' }
});
expect(model.data.get('bar')).to.be('baz');
});
});
describe('#metadata', () => {
it('should be the metadata observable map', () => {
let model = new MimeModel({
metadata: { 'bar': 'baz' }
});
expect(model.metadata.get('bar')).to.be('baz');
});
});
describe('#toJSON()', () => {
it('should return the raw JSON values', () => {
let model = new MimeModel();
model.data.set('foo', 1);
model.metadata.set('bar', 'baz');
expect(JSONExt.deepEqual(model.toJSON(), {
trusted: false,
data: {'foo': 1 },
metadata: {'bar': 'baz'}
})).to.be(true);
});
});
});
});