Skip to content

Commit

Permalink
fix: failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
201flaviosilva committed May 29, 2023
1 parent 1f82129 commit 4a8f7ca
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
_ignore
docs
coverage
package-lock.json

# Logs
logs
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dev": "vite",
"test": "vitest --watch=false",
"test:dev": "vitest",
"coverage": "vitest run --coverage",
"jsdoc": "jsdoc -c jsdoc.conf.json",
"types": "npx -p typescript tsc src/*.js --declaration --allowJs --emitDeclarationOnly --outDir types",
"compile": "vite build",
Expand Down
5 changes: 3 additions & 2 deletions tests/Arrays/choice.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { Arrays } from "./src/main";
const { choice } = Arrays;

describe("Arrays/choice.js", () => {
let spy;
beforeEach(() => {
vitest.spyOn(global.Math, "random").mockReturnValue(0.1);
spy = vitest.spyOn(global.Math, "random").mockReturnValue(0.1);
});
afterEach(() => {
vitest.spyOn(global.Math, "random").mockRestore();
spy.mockRestore();
});

it("should return A", () => {
Expand Down
6 changes: 4 additions & 2 deletions tests/choiceTrend.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { choiceTrend } from "./src/main";

describe("choiceTrend.js", () => {
let spy;

beforeEach(() => {
vitest.spyOn(global.Math, "random").mockReturnValue(0.5);
spy = vitest.spyOn(global.Math, "random").mockReturnValue(0.5);
});
afterEach(() => {
vitest.spyOn(global.Math, "random").mockRestore();
spy.mockRestore();
});

it("should return 1 for the defaults values", () => {
Expand Down
1 change: 0 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default defineConfig({
globals: true,
coverage: {
reporter: ["text", "json", "html"],
provider: "istanbul" // or "c8"
},
},
})

0 comments on commit 4a8f7ca

Please sign in to comment.