add config unit test cases for pie chart

This commit is contained in:
Yokozuna59 2023-06-19 17:46:19 +03:00
parent c894c1f5b5
commit 35c6b671de

View File

@ -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);
});
});
});