mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-12 20:09:46 +02:00
add config unit test cases for pie chart
This commit is contained in:
@@ -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
|
||||||
@@ -145,4 +147,23 @@ 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user