Support multi-line script.

This commit is contained in:
Yang Chen
2019-12-13 18:17:53 +11:00
committed by ychescale9
parent ae2123e35c
commit 9739504a54
8 changed files with 114 additions and 19 deletions
+33
View File
@@ -0,0 +1,33 @@
import * as parser from '../src/script-parser';
describe('script parser tests', () => {
it('Scripts are trimmed', () => {
const script = ` command \n`;
expect(parser.parseScript(script)).toEqual(['command']);
});
it('Commented lines are filtered out', () => {
const script = `
# command1
command2
# command3
command4
`;
expect(parser.parseScript(script)).toEqual(['command2', 'command4']);
});
it('Throws if parsed scripts array is empty', () => {
const func = () => {
const script = `
# command1
# command2
`;
const result = parser.parseScript(script);
console.log(`Result: ${result}`);
};
expect(func).toThrowError(`No valid script found.`);
});
});