forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nbformat.spec.ts
50 lines (33 loc) · 1.26 KB
/
nbformat.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
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import {
expect
} from 'chai';
import {
nbformat
} from '@jupyterlab/coreutils';
const VALIDATE = nbformat.validateMimeValue;
describe('@jupyterlab/coreutils', () => {
describe('nbformat', () => {
describe('validateMimeValue', () => {
it('should return true for a valid json object', () => {
expect(VALIDATE('application/json', { 'foo': 1 })).to.equal(true);
});
it('should return true for a valid json-like object', () => {
expect(VALIDATE('application/foo+json', { 'foo': 1 })).to.equal(true);
});
it('should return true for a valid string object', () => {
expect(VALIDATE('text/plain', 'foo')).to.equal(true);
});
it('should return true for a valid array of strings object', () => {
expect(VALIDATE('text/plain', ['foo', 'bar'])).to.equal(true);
});
it('should return false for a json type with string data', () => {
expect(VALIDATE('application/foo+json', 'bar')).to.equal(false);
});
it('should return false for a string type with json data', () => {
expect(VALIDATE('foo/bar', { 'foo': 1 })).to.equal(false);
});
});
});
});