Skip to content

Commit 430490d

Browse files
author
Fabian Morón Zirfas
committed
setup tests with jest
1 parent 41fce82 commit 430490d

File tree

4 files changed

+4854
-2
lines changed

4 files changed

+4854
-2
lines changed

__tests__/array.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// @ts-nocheck
2+
const arrayEvery = Array.prototype.every;
3+
const arrayFilter = Array.prototype.filter;
4+
beforeAll(() => {
5+
Array.prototype.every = undefined;
6+
Array.prototype.filter = undefined;
7+
});
8+
afterAll(() => {
9+
Array.prototype.every = arrayEvery;
10+
Array.prototype.filter = arrayFilter;
11+
});
12+
describe("array tests", () => {
13+
test("filter should work", () => {
14+
require("../Array/filter");
15+
const arr = [1, 2, 3];
16+
const res = arr.filter((ele, i, arr) => ele === 1);
17+
expect(res[0]).toBe(1);
18+
});
19+
test("every shoud work", () => {
20+
require("../Array/every");
21+
const arr = [1, 2, 3];
22+
expect(
23+
arr.every(function(ele, i, arr) {
24+
return ele < 4;
25+
})
26+
).toBe(true);
27+
});
28+
});

jest.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
testEnvironment: "jest-environment-node",
3+
collectCoverage: true,
4+
coverageReporters: ["lcov", "text"],
5+
collectCoverageFrom: [
6+
"Array/**/*.{js}",
7+
"Date/**/*.{js}",
8+
"Object/**/*.{js}"
9+
],
10+
coverageThreshold: {
11+
global: {
12+
branches: 75,
13+
functions: 75,
14+
lines: 75,
15+
statements: 75
16+
}
17+
}
18+
};

0 commit comments

Comments
 (0)