2023-09-16 00:26:24 +01:00
|
|
|
import { imgSnapshotTest, urlSnapshotTest } from '../../helpers/util.ts';
|
2020-07-29 18:38:59 +02:00
|
|
|
|
|
|
|
describe('Configuration and directives - nodes should be light blue', () => {
|
2021-11-18 19:17:00 +01:00
|
|
|
it('No config - use default', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
2020-07-29 18:38:59 +02:00
|
|
|
graph TD
|
|
|
|
A(Default) --> B[/Another/]
|
|
|
|
A --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
2021-11-18 19:17:00 +01:00
|
|
|
{}
|
|
|
|
);
|
|
|
|
});
|
2022-06-27 12:29:50 +09:00
|
|
|
it('Settings from initialize - nodes should be green', () => {
|
2021-11-18 19:17:00 +01:00
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
2020-07-29 18:38:59 +02:00
|
|
|
graph TD
|
|
|
|
A(Forest) --> B[/Another/]
|
|
|
|
A --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end `,
|
2021-11-18 19:17:00 +01:00
|
|
|
{ theme: 'forest' }
|
|
|
|
);
|
|
|
|
});
|
2022-06-27 12:29:50 +09:00
|
|
|
it('Settings from initialize overriding themeVariable - nodes should be red', () => {
|
2021-11-18 19:17:00 +01:00
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
2020-07-29 18:38:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
%%{init: { 'theme': 'base', 'themeVariables':{ 'primaryColor': '#ff0000'}}}%%
|
|
|
|
graph TD
|
|
|
|
A(Start) --> B[/Another/]
|
|
|
|
A[/Another/] --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
2021-11-18 19:17:00 +01:00
|
|
|
{ theme: 'base', themeVariables: { primaryColor: '#ff0000' }, logLevel: 0 }
|
|
|
|
);
|
|
|
|
});
|
|
|
|
it('Settings from directive - nodes should be grey', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
2020-07-29 18:38:59 +02:00
|
|
|
%%{init: { 'logLevel': 0, 'theme': 'neutral'} }%%
|
|
|
|
graph TD
|
|
|
|
A(Start) --> B[/Another/]
|
|
|
|
A[/Another/] --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
2021-11-18 19:17:00 +01:00
|
|
|
{}
|
|
|
|
);
|
2023-08-21 12:09:38 +05:30
|
|
|
});
|
|
|
|
it('Settings from frontmatter - nodes should be grey', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
---
|
|
|
|
config:
|
|
|
|
theme: neutral
|
|
|
|
---
|
|
|
|
graph TD
|
|
|
|
A(Start) --> B[/Another/]
|
|
|
|
A[/Another/] --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
2021-11-18 19:17:00 +01:00
|
|
|
});
|
2020-07-29 18:38:59 +02:00
|
|
|
|
2021-11-18 19:17:00 +01:00
|
|
|
it('Settings from directive overriding theme variable - nodes should be red', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
2020-07-29 18:38:59 +02:00
|
|
|
%%{init: {'theme': 'base', 'themeVariables':{ 'primaryColor': '#ff0000'}}}%%
|
|
|
|
graph TD
|
|
|
|
A(Start) --> B[/Another/]
|
|
|
|
A[/Another/] --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
2021-11-18 19:17:00 +01:00
|
|
|
{}
|
|
|
|
);
|
2020-07-29 18:38:59 +02:00
|
|
|
});
|
2021-11-18 19:17:00 +01:00
|
|
|
it('Settings from initialize and directive - nodes should be grey', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
2020-07-29 18:38:59 +02:00
|
|
|
%%{init: { 'logLevel': 0, 'theme': 'neutral'} }%%
|
|
|
|
graph TD
|
|
|
|
A(Start) --> B[/Another/]
|
|
|
|
A[/Another/] --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
2021-11-18 19:17:00 +01:00
|
|
|
{ theme: 'forest' }
|
|
|
|
);
|
|
|
|
});
|
|
|
|
it('Theme from initialize, directive overriding theme variable - nodes should be red', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
2020-07-29 18:38:59 +02:00
|
|
|
%%{init: {'theme': 'base', 'themeVariables':{ 'primaryColor': '#ff0000'}}}%%
|
|
|
|
graph TD
|
|
|
|
A(Start) --> B[/Another/]
|
|
|
|
A[/Another/] --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
2021-11-18 19:17:00 +01:00
|
|
|
{ theme: 'base' }
|
|
|
|
);
|
|
|
|
});
|
2023-08-21 12:09:38 +05:30
|
|
|
it('Theme from initialize, frontmatter overriding theme variable - nodes should be red', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
---
|
|
|
|
config:
|
|
|
|
theme: base
|
|
|
|
themeVariables:
|
|
|
|
primaryColor: '#ff0000'
|
|
|
|
---
|
2023-08-21 12:30:04 +05:30
|
|
|
graph TD
|
|
|
|
A(Start) --> B[/Another/]
|
|
|
|
A[/Another/] --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
|
|
|
{ theme: 'forest' }
|
|
|
|
);
|
|
|
|
});
|
|
|
|
it('Theme from initialize, frontmatter overriding theme variable, directive overriding primaryColor - nodes should be red', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
---
|
|
|
|
config:
|
|
|
|
theme: base
|
|
|
|
themeVariables:
|
|
|
|
primaryColor: '#00ff00'
|
|
|
|
---
|
|
|
|
%%{init: {'theme': 'base', 'themeVariables':{ 'primaryColor': '#ff0000'}}}%%
|
2023-08-21 12:09:38 +05:30
|
|
|
graph TD
|
|
|
|
A(Start) --> B[/Another/]
|
|
|
|
A[/Another/] --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
|
|
|
{ theme: 'forest' }
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render if values are not quoted properly', () => {
|
|
|
|
// #ff0000 is not quoted properly, and will evaluate to null.
|
|
|
|
// This test ensures that the rendering still works.
|
|
|
|
imgSnapshotTest(
|
|
|
|
`---
|
|
|
|
config:
|
|
|
|
theme: base
|
|
|
|
themeVariables:
|
|
|
|
primaryColor: #ff0000
|
|
|
|
---
|
|
|
|
graph TD
|
|
|
|
A(Start) --> B[/Another/]
|
|
|
|
A[/Another/] --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
|
|
|
{ theme: 'forest' }
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2021-11-18 19:17:00 +01:00
|
|
|
it('Theme variable from initialize, theme from directive - nodes should be red', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
2020-07-29 18:38:59 +02:00
|
|
|
%%{init: { 'logLevel': 0, 'theme': 'base'} }%%
|
|
|
|
graph TD
|
|
|
|
A(Start) --> B[/Another/]
|
|
|
|
A[/Another/] --> C[End]
|
|
|
|
subgraph section
|
|
|
|
B
|
|
|
|
C
|
|
|
|
end
|
|
|
|
`,
|
2021-11-18 19:17:00 +01:00
|
|
|
{ themeVariables: { primaryColor: '#ff0000' } }
|
|
|
|
);
|
|
|
|
});
|
|
|
|
describe('when rendering several diagrams', () => {
|
|
|
|
it('diagrams should not taint later diagrams', () => {
|
|
|
|
const url = 'http://localhost:9000/theme-directives.html';
|
2023-09-16 00:26:24 +01:00
|
|
|
urlSnapshotTest(url, {});
|
2020-07-29 18:38:59 +02:00
|
|
|
});
|
|
|
|
});
|
2021-11-18 19:17:00 +01:00
|
|
|
});
|