mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
test: rewrite some config
vals to tighten types
We're planning on limiting some of MermaidConfig's types to specific values (e.g. `0 | 1` instead of `number`).
This commit is contained in:
parent
6e51f8fd98
commit
77ba7c987a
@ -563,7 +563,7 @@ describe('mermaidAPI', () => {
|
||||
const config = {
|
||||
logLevel: 0,
|
||||
securityLevel: 'loose',
|
||||
};
|
||||
} as const;
|
||||
mermaidAPI.initialize(config);
|
||||
mermaidAPI.setConfig({ securityLevel: 'strict', logLevel: 1 });
|
||||
expect(mermaidAPI.getConfig().logLevel).toBe(1);
|
||||
|
@ -260,56 +260,46 @@ describe('when formatting urls', function () {
|
||||
it('should handle links', function () {
|
||||
const url = 'https://mermaid-js.github.io/mermaid/#/';
|
||||
|
||||
const config = { securityLevel: 'loose' };
|
||||
let result = utils.formatUrl(url, config);
|
||||
let result = utils.formatUrl(url, { securityLevel: 'loose' });
|
||||
expect(result).toEqual(url);
|
||||
|
||||
config.securityLevel = 'strict';
|
||||
result = utils.formatUrl(url, config);
|
||||
result = utils.formatUrl(url, { securityLevel: 'strict' });
|
||||
expect(result).toEqual(url);
|
||||
});
|
||||
it('should handle anchors', function () {
|
||||
const url = '#interaction';
|
||||
|
||||
const config = { securityLevel: 'loose' };
|
||||
let result = utils.formatUrl(url, config);
|
||||
let result = utils.formatUrl(url, { securityLevel: 'loose' });
|
||||
expect(result).toEqual(url);
|
||||
|
||||
config.securityLevel = 'strict';
|
||||
result = utils.formatUrl(url, config);
|
||||
result = utils.formatUrl(url, { securityLevel: 'strict' });
|
||||
expect(result).toEqual(url);
|
||||
});
|
||||
it('should handle mailto', function () {
|
||||
const url = 'mailto:user@user.user';
|
||||
|
||||
const config = { securityLevel: 'loose' };
|
||||
let result = utils.formatUrl(url, config);
|
||||
let result = utils.formatUrl(url, { securityLevel: 'loose' });
|
||||
expect(result).toEqual(url);
|
||||
|
||||
config.securityLevel = 'strict';
|
||||
result = utils.formatUrl(url, config);
|
||||
result = utils.formatUrl(url, { securityLevel: 'strict' });
|
||||
expect(result).toEqual(url);
|
||||
});
|
||||
it('should handle other protocols', function () {
|
||||
const url = 'notes://do-your-thing/id';
|
||||
|
||||
const config = { securityLevel: 'loose' };
|
||||
let result = utils.formatUrl(url, config);
|
||||
let result = utils.formatUrl(url, { securityLevel: 'loose' });
|
||||
expect(result).toEqual(url);
|
||||
|
||||
config.securityLevel = 'strict';
|
||||
result = utils.formatUrl(url, config);
|
||||
result = utils.formatUrl(url, { securityLevel: 'strict' });
|
||||
expect(result).toEqual(url);
|
||||
});
|
||||
it('should handle scripts', function () {
|
||||
const url = 'javascript:alert("test")';
|
||||
|
||||
const config = { securityLevel: 'loose' };
|
||||
let result = utils.formatUrl(url, config);
|
||||
let result = utils.formatUrl(url, { securityLevel: 'loose' });
|
||||
expect(result).toEqual(url);
|
||||
|
||||
config.securityLevel = 'strict';
|
||||
result = utils.formatUrl(url, config);
|
||||
result = utils.formatUrl(url, { securityLevel: 'strict' });
|
||||
expect(result).toEqual('about:blank');
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user