1 |
|
2 | import mermaidAPI from './mermaidAPI'
|
3 |
|
4 | describe('when using mermaidAPI and ', function () {
|
5 | describe('doing initialize ', function () {
|
6 | beforeEach(function () {
|
7 | document.body.innerHTML = ''
|
8 | })
|
9 |
|
10 | it('should copy a literal into the configuration', function () {
|
11 | const orgConfig = mermaidAPI.getConfig()
|
12 | expect(orgConfig.testLiteral).toBe(undefined)
|
13 |
|
14 | mermaidAPI.initialize({ 'testLiteral': true })
|
15 | const config = mermaidAPI.getConfig()
|
16 |
|
17 | expect(config.testLiteral).toBe(true)
|
18 | })
|
19 | it('should copy a an object into the configuration', function () {
|
20 | const orgConfig = mermaidAPI.getConfig()
|
21 | expect(orgConfig.testObject).toBe(undefined)
|
22 |
|
23 | const object = {
|
24 | test1: 1,
|
25 | test2: false
|
26 | }
|
27 |
|
28 | mermaidAPI.initialize({ 'testObject': object })
|
29 | mermaidAPI.initialize({ 'testObject': { 'test3': true } })
|
30 | const config = mermaidAPI.getConfig()
|
31 |
|
32 | expect(config.testObject.test1).toBe(1)
|
33 | expect(config.testObject.test2).toBe(false)
|
34 | expect(config.testObject.test3).toBe(true)
|
35 | })
|
36 | })
|
37 | describe('checking validity of input ', function () {
|
38 | it('it should throw for an invalid definiton', function () {
|
39 | expect(() => mermaidAPI.parse('this is not a mermaid diagram definition')).toThrow()
|
40 | })
|
41 | it('it should not throw for a valid definiton', function () {
|
42 | expect(() => mermaidAPI.parse('graph TD;A--x|text including URL space|B;')).not.toThrow()
|
43 | })
|
44 | })
|
45 | })
|