Skip to content

Commit 054219c

Browse files
committed
refactor: only compile validator function once
1 parent 808169e commit 054219c

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/schema/keywords/function.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const schema = {
1212
},
1313
},
1414
};
15+
const validate = ajv.compile(schema);
1516

1617
it("should give error if value isn't function", () => {
1718
expect.assertions(2);
18-
const validate = ajv.compile(schema);
1919
const result = validate({
2020
foo: "spam",
2121
});
@@ -35,7 +35,6 @@ it("should give error if value isn't function", () => {
3535

3636
it("should not give error if value is function", () => {
3737
expect.assertions(2);
38-
const validate = ajv.compile(schema);
3938
function foo(): void {
4039
/* do nothing */
4140
}
@@ -48,7 +47,6 @@ it("should not give error if value is function", () => {
4847

4948
it("should not give error if value is arrow function", () => {
5049
expect.assertions(2);
51-
const validate = ajv.compile(schema);
5250
const result = validate({
5351
foo: (): void => {
5452
/* do nothing */
@@ -60,7 +58,6 @@ it("should not give error if value is arrow function", () => {
6058

6159
it("should not give error if value is method", () => {
6260
expect.assertions(2);
63-
const validate = ajv.compile(schema);
6461
const result = validate({
6562
foo(): void {
6663
/* do nothing */

0 commit comments

Comments
 (0)