-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge testrunner example and javascript tests into json.test.js
- Loading branch information
Showing
3 changed files
with
34 additions
and
6 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
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 fs from 'fs' | ||
import { expect, test, describe } from "bun:test"; | ||
import { evaluate } from '../src/index.js' | ||
|
||
const testDirectory = '../tests/'; | ||
const files = fs.readdirSync(testDirectory); | ||
|
||
files.forEach(f => { | ||
const testGroup = JSON.parse(fs.readFileSync(testDirectory + f)); | ||
const resources = testGroup.resources; | ||
|
||
testGroup.tests.forEach(testCase => { | ||
const view = testCase.view; | ||
|
||
describe(f, () => { | ||
if (testCase.expect !== undefined) { | ||
test(testCase.title, () => { | ||
const res = evaluate(view, resources); | ||
expect(res).toEqual(testCase.expect); | ||
}); | ||
} else if (testCase.expectError !== undefined) { | ||
test(testCase.title, () => { | ||
expect(() => evaluate(view, resources)).toThrow(); | ||
Check failure on line 23 in sof-js/tests/json.test.js
|
||
}); | ||
} else if (testCase.expectCount !== undefined) { | ||
throw new Error("expectCount is not implemented yet"); | ||
} else { | ||
throw new Error(`'${testCase.title}' test has no known expectation`); | ||
} | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -240,11 +240,7 @@ | |
} | ||
] | ||
}, | ||
"expect": [ | ||
{ | ||
"id": "pt1" | ||
} | ||
] | ||
"expectError": true | ||
}, | ||
{ | ||
"title": "where as expr - 1", | ||
|