fix: Info diagram case sensitivity

This commit is contained in:
Sidharth Vinod
2022-09-08 20:48:28 +05:30
parent 6138dd8714
commit 00dc2d73de
2 changed files with 18 additions and 10 deletions

View File

@@ -35,11 +35,19 @@ describe('when parsing an info graph it', function () {
}).toThrow();
});
// TODO
// it('should no throw an error when showInfo is not defined', function () {
// expect(() => {
// infoParser.parse('info');
// }).not.toThrow();
// expect(infoDb.getInfo()).toEqual(false);
// });
it('should not throw an error when showInfo is not defined', function () {
infoParser.parse('info');
expect(infoDb.getInfo()).toEqual(true);
});
it.each([
`InFo`,
`Info
showinfo`,
`info
shOWINFO`,
])('should be case insensitive', function (str) {
infoParser.parse(str);
expect(infoDb.getInfo()).toEqual(true);
});
});

View File

@@ -2,8 +2,8 @@ import { createToken, EmbeddedActionsParser, Lexer } from 'chevrotain';
import { log } from '../../logger';
import infoDb from './infoDb';
const Info = createToken({ name: 'Info', pattern: /info/ });
const ShowInfo = createToken({ name: 'ShowInfo', pattern: /showInfo/ });
const Info = createToken({ name: 'Info', pattern: /info/i });
const ShowInfo = createToken({ name: 'ShowInfo', pattern: /showInfo/i });
const NewLine = createToken({
name: 'NewLine',
pattern: /\r?\n/,
@@ -44,7 +44,7 @@ class InfoParser extends EmbeddedActionsParser {
public hdr = this.RULE('hdr', () => {
this.CONSUME(Info);
this.CONSUME(NewLine);
this.OPTION(() => this.CONSUME(NewLine));
});
public row = this.RULE('row', () => {