Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Nov 21, 2024
1 parent dd5e60e commit f7e163d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Node.js: Debug TSDX Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/tsdx/dist/index.js",
"test",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@
"json-schema",
"errors",
"human"
]
],
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
20 changes: 20 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ describe('betterAjvErrors', () => {
};
});

describe('combined schemas', () => {
it('should handle type errors', () => {
data = {
str: 123,
};
const combinedSchema = {type: 'boolean'};
const validateCombined = ajv.addSchema(combinedSchema).compile(schema);
validateCombined(data);
const betterErrors = betterAjvErrors({ data, schema, errors: validateCombined.errors });
expect(betterErrors).toEqual([
{
context: {
errorType: 'type',
},
message: "'str' property type must be string",
path: '{base}.str',
},
]);
});
});
describe('additionalProperties', () => {
it('should handle additionalProperties=false', () => {
data = {
Expand Down

0 comments on commit f7e163d

Please sign in to comment.