mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-15 10:14:21 +01:00
Fixed parsers to use the correct type name in close_directive
Added directive support to pie (Refactored pie parsing to be a bit more clear) Added more unit tests to pie
This commit is contained in:
@@ -13,15 +13,57 @@ describe('when parsing pie', function() {
|
||||
pie.parser.yy.clear();
|
||||
});
|
||||
it('should handle simple pie', function() {
|
||||
const res = pie.parser.parse('pie \n"ash" : 60\n"bat" : 40\n');
|
||||
const res = pie.parser.parse(`pie
|
||||
"ash" : 60
|
||||
"bat" : 40
|
||||
`);
|
||||
const sections = pieDb.getSections();
|
||||
console.log('sections: ', sections);
|
||||
const section1 = sections['ash'];
|
||||
expect(section1).toBe(60);
|
||||
});
|
||||
it('should handle simple pie with comments', function() {
|
||||
const res = pie.parser.parse(`pie
|
||||
%% comments
|
||||
"ash" : 60
|
||||
"bat" : 40
|
||||
`);
|
||||
const sections = pieDb.getSections();
|
||||
console.log('sections: ', sections);
|
||||
const section1 = sections['ash'];
|
||||
expect(section1).toBe(60);
|
||||
});
|
||||
|
||||
it('should handle simple pie with a directive', function() {
|
||||
const res = pie.parser.parse(`%%{init: {'logLevel':0}}%%
|
||||
pie
|
||||
"ash" : 60
|
||||
"bat" : 40
|
||||
`);
|
||||
const sections = pieDb.getSections();
|
||||
console.log('sections: ', sections);
|
||||
const section1 = sections['ash'];
|
||||
expect(section1).toBe(60);
|
||||
});
|
||||
|
||||
it('should handle simple pie with a title', function() {
|
||||
const res = pie.parser.parse(`pie title a 60/40 pie
|
||||
"ash" : 60
|
||||
"bat" : 40
|
||||
`);
|
||||
const sections = pieDb.getSections();
|
||||
const title = pieDb.getTitle();
|
||||
console.log('sections: ', sections);
|
||||
const section1 = sections['ash'];
|
||||
expect(section1).toBe(60);
|
||||
expect(title).toBe('a 60/40 pie');
|
||||
});
|
||||
|
||||
it('should handle simple pie with positive decimal', function() {
|
||||
const res = pie.parser.parse('pie \n"ash" : 60.67\n"bat" : 40\n');
|
||||
const res = pie.parser.parse(`pie
|
||||
"ash" : 60.67
|
||||
"bat" : 40
|
||||
`);
|
||||
const sections = pieDb.getSections();
|
||||
console.log('sections: ', sections);
|
||||
const section1 = sections['ash'];
|
||||
@@ -30,7 +72,10 @@ describe('when parsing pie', function() {
|
||||
|
||||
it('should handle simple pie with negative decimal', function() {
|
||||
expect(() => {
|
||||
pie.parser.parse('pie \n"ash" : 60.67\n"bat" : 40..12\n');
|
||||
pie.parser.parse(`pie
|
||||
"ash" : 60.67
|
||||
"bat" : 40..12
|
||||
`);
|
||||
}).toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user