Skip to content

Commit

Permalink
test(core): cover all branches in visitor.ts with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino committed Jul 3, 2024
1 parent e5b4112 commit 7010163
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions pkg/core/test/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,54 @@ test('visitor works', (t) => {
test('visitor throws error correctly', (t) => {
(
[
[
{ data: {}, keys: {} },
{
givenThen: 'given',
errors: [
{
message: new Error('at 1\n missing one of: Given I, Then I'),
lineNo: 1
}
],
matches: [],
},
'cst must not have any general errors'
],
[
{ data: {}, keys: {} },
{
givenThen: 'given',
errors: [],
matches: [],
},
'cst must have only one match'
],
[
{ data: {}, keys: {} },
{
givenThen: 'given',
errors: [],
matches: [
{
key: {
phrase: 'a b c'
},
bindings: new Map(),
err: [
{
message: new Error('at 1:19.22\n save may be and'),
lineNo: 1,
start: 19,
end: 22
}
],
lineNo: 1
}
]
},
'cst\'s match must not have any errors'
],
[
{ data: {}, keys: {} },
{
Expand Down Expand Up @@ -215,6 +263,25 @@ test('visitor throws error correctly', (t) => {
},
'the array referenced by myFile must solely composed of strings'
],
[
{ data: {}, keys: {} },
{
givenThen: 'given',
errors: [],
matches: [
{
key: {
params: ['object'],
phrase: 'a b c'
},
bindings: new Map([['object', 'myObj']]),
err: [],
lineNo: 1
},
],
},
'Can\'t find myObj in DATA or KEYS'
],
] as [ZenParams, Cst, string][]
).forEach(([params, cst, errMessage]) => {
const err = t.throws(() => {
Expand Down

0 comments on commit 7010163

Please sign in to comment.