Skip to content

Commit

Permalink
fix: change min duration from 5 to 1 (#37)
Browse files Browse the repository at this point in the history
* fix: added 1 to duration option

* test: update test

Co-authored-by: Benedicte Raae <[email protected]>
  • Loading branch information
olavea and raae authored Dec 24, 2021
1 parent c82854b commit 46b8d62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion plugin/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports.pluginOptionsSchema = ({ Joi }) => {
.default("regular"),
duration: Joi.number()
.integer()
.min(5)
.min(1)
.default(15)
.description("Duration of snowfall in seconds"),
season: Joi.object()
Expand Down
15 changes: 6 additions & 9 deletions plugin/gatsby-node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe("pluginOptionsSchema", () => {
});

describe("duration", () => {
it("valid for int over 4", async () => {
it("valid for int over 0", async () => {
const options = {
duration: 10,
};
Expand All @@ -130,7 +130,7 @@ describe("pluginOptionsSchema", () => {
expect(isValid).toBe(true);
});

it("valid for int string over 4", async () => {
it("valid for int string over 0", async () => {
const options = {
duration: "16",
};
Expand All @@ -142,17 +142,17 @@ describe("pluginOptionsSchema", () => {
expect(isValid).toBe(true);
});

it("invalid for int under 5", async () => {
it("invalid for int under 1", async () => {
const options = {
duration: 3,
duration: 0,
};
const { isValid, errors } = await testPluginOptionsSchema(
pluginOptionsSchema,
options
);

expect(isValid).toBe(false);
expect(errors).toEqual([`"duration" must be greater than or equal to 5`]);
expect(errors).toEqual([`"duration" must be greater than or equal to 1`]);
});

it("invalid for float", async () => {
Expand All @@ -165,10 +165,7 @@ describe("pluginOptionsSchema", () => {
);

expect(isValid).toBe(false);
expect(errors).toEqual([
`"duration" must be an integer`,
`"duration" must be greater than or equal to 5`,
]);
expect(errors).toEqual([`"duration" must be an integer`]);
});

it("invalid for non int string", async () => {
Expand Down

0 comments on commit 46b8d62

Please sign in to comment.