mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03: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
|
// @ts-ignore - jison doesn't export types
|
||||||
import { parser } from './parser/pie.jison';
|
import { parser } from './parser/pie.jison';
|
||||||
import { db } from './pieDb.js';
|
import { DEFAULT_PIE_DB, db } from './pieDb.js';
|
||||||
import { setConfig } from '../../config.js';
|
import { setConfig } from '../../config.js';
|
||||||
|
|
||||||
setConfig({
|
setConfig({
|
||||||
@ -10,9 +10,11 @@ setConfig({
|
|||||||
describe('pie chart', () => {
|
describe('pie chart', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
parser.yy = db;
|
parser.yy = db;
|
||||||
parser.yy.clear();
|
db.clear();
|
||||||
|
db.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('parse', () => {
|
||||||
it('should handle very simple pie', () => {
|
it('should handle very simple pie', () => {
|
||||||
parser.parse(`pie
|
parser.parse(`pie
|
||||||
"ash": 100
|
"ash": 100
|
||||||
@ -146,3 +148,22 @@ describe('pie chart', () => {
|
|||||||
}).toThrowError();
|
}).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