-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix conditional tag parsing; Add unit tests for conditional tag parser
- Loading branch information
Showing
3 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { parseConditionalTag } from '../utils/conditional-tag' | ||
|
||
describe('#parseConditionalTag()', () => { | ||
test('one value', async() => { | ||
const values = parseConditionalTag('free @ (Mo-Fr 09:00-19:00)') | ||
expect(values).toStrictEqual([ | ||
{ value: 'free', condition: 'Mo-Fr 09:00-19:00' }, | ||
]) | ||
}) | ||
test('two value; without brackets', async() => { | ||
const values = parseConditionalTag('free @ (Mo-Fr 09:00-19:00); ticket @ 19:00-20:00') | ||
expect(values).toStrictEqual([ | ||
{ value: 'free', condition: 'Mo-Fr 09:00-19:00' }, | ||
{ value: 'ticket', condition: '19:00-20:00' }, | ||
]) | ||
}) | ||
test('two values; value without condition', async() => { | ||
const values = parseConditionalTag('free @ (Mo-Fr 09:00-19:00); ticket') | ||
expect(values).toStrictEqual([ | ||
{ value: 'free', condition: 'Mo-Fr 09:00-19:00' }, | ||
{ value: 'ticket', condition: null }, | ||
]) | ||
}) | ||
test('free values; without brackets; condition with semicolons; ends with semicolon', async() => { | ||
const values = parseConditionalTag('free @ (Mo-Fr 09:00-19:00);ticket@19:00-20:00 ; residents @ (Mo-Fr 07:00-09:00,15:00-18:00; Sa 09:00-15:00);') | ||
expect(values).toStrictEqual([ | ||
{ value: 'free', condition: 'Mo-Fr 09:00-19:00' }, | ||
{ value: 'ticket', condition: '19:00-20:00' }, | ||
{ value: 'residents', condition: 'Mo-Fr 07:00-09:00,15:00-18:00; Sa 09:00-15:00' }, | ||
]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters