mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-21 06:53:17 +08:00
add config unit test cases for pie chart
This commit is contained in:
parent
c894c1f5b5
commit
35c6b671de
@ -1,6 +1,6 @@
|
||||
// @ts-ignore - jison doesn't export types
|
||||
import { parser } from './parser/pie.jison';
|
||||
import { db } from './pieDb.js';
|
||||
import { DEFAULT_PIE_DB, db } from './pieDb.js';
|
||||
import { setConfig } from '../../config.js';
|
||||
|
||||
setConfig({
|
||||
@ -10,9 +10,11 @@ setConfig({
|
||||
describe('pie chart', () => {
|
||||
beforeEach(() => {
|
||||
parser.yy = db;
|
||||
parser.yy.clear();
|
||||
db.clear();
|
||||
db.reset();
|
||||
});
|
||||
|
||||
describe('parse', () => {
|
||||
it('should handle very simple pie', () => {
|
||||
parser.parse(`pie
|
||||
"ash": 100
|
||||
@ -146,3 +148,22 @@ describe('pie chart', () => {
|
||||
}).toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
describe('config', () => {
|
||||
it('setConfig', () => {
|
||||
db.setConfig({ useWidth: 850, useMaxWidth: undefined });
|
||||
expect(db.getConfig().useWidth).toBe(850);
|
||||
expect(db.getConfig().useMaxWidth).toBeTruthy();
|
||||
});
|
||||
|
||||
it('getConfig', () => {
|
||||
expect(db.getConfig()).toStrictEqual(DEFAULT_PIE_DB.config);
|
||||
});
|
||||
|
||||
it('reset', () => {
|
||||
db.setConfig({ useWidth: 850 });
|
||||
db.reset();
|
||||
expect(db.getConfig().useWidth).toStrictEqual(DEFAULT_PIE_DB.config.useWidth);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user