Skip to content

Commit

Permalink
test: add a test for maxItems
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Feb 22, 2021
1 parent 76b8b0b commit 2680cb9
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion packages/plugin-manifest-validator/src/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ describe("validator", () => {
message: "should be >= 1",
params: {
comparison: ">=",
// exclusive: false,
limit: 1,
},
schemaPath: "#/properties/version/minimum",
Expand Down Expand Up @@ -239,6 +238,31 @@ describe("validator", () => {
assert(actual.errors === null);
});
});
describe("maxItems", () => {
it("exceed the max item counts", () => {
const urls = [...new Array(100)].map(
(_, i) => `https://example.com/${i}.js`
);
const actual = validator(
json({
desktop: {
js: urls,
},
})
);
assert.strictEqual(actual.valid, false);
assert.strictEqual(actual.errors?.length, 1);
assert.deepStrictEqual(actual.errors[0], {
dataPath: "/desktop/js",
keyword: "maxItems",
message: "should NOT have more than 30 items",
params: {
limit: 30,
},
schemaPath: "#/definitions/resources/maxItems",
});
});
});
});

/**
Expand Down

0 comments on commit 2680cb9

Please sign in to comment.