1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/test/frontend/lib/parsing.test.ts
2023-02-15 10:30:14 +01:00

29 lines
919 B
TypeScript

import ParsingLib from 'lib/parsing';
describe('ParsingLib', () => {
test('parse a boolean', () => {
const res = ParsingLib.simpleParse('true');
expect(res).toBe(true);
});
test('parse a number', () => {
const res = ParsingLib.simpleParse('10');
expect(res).toBe(10);
});
test('parse an array of numbers', () => {
const res = ParsingLib.parse(['10', '20', '30']);
expect(res).toEqual([10, 20, 30]);
});
test('parse an array of booleans', () => {
const res = ParsingLib.parse(['true', 'false']);
expect(res).toEqual([true, false]);
});
test('parse a mixed array', () => {
const res = ParsingLib.parse(['true', '10', 'foo']);
expect(res).toEqual([true, 10, 'foo']);
});
test('parse an array of arrays', () => {
const res = ParsingLib.parse([['bar', '10'], ['true', 'foo'], 'baz']);
expect(res).toEqual([['bar', 10], [true, 'foo'], 'baz']);
});
});