Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Commit

Permalink
Cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ianschmitz committed Nov 28, 2019
1 parent 3d2e617 commit b4e5264
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -11,7 +11,7 @@
],
"scripts": {
"test": "jest",
"build": "rimraf lib && tsc"
"build": "rimraf lib && tsc -p ./tsconfig.build.json"
},
"dependencies": {
"@jest/environment": "^24.3.0",
Expand Down
20 changes: 14 additions & 6 deletions src/__tests__/index.test.ts
@@ -1,14 +1,22 @@

const JSDomEnvironment = jest.requireActual("../index");
import JSDomEnvironment from "../";

describe("JSDomEnvironment", () => {
let instance: JSDomEnvironment | undefined;

afterEach(async () => {
if (instance) {
await instance.teardown();
instance = undefined;
}
});

it("should configure setTimeout/setInterval to use the browser api", () => {
const env1 = new JSDomEnvironment({});
instance = new JSDomEnvironment({} as any);

env1.fakeTimers.useFakeTimers();
instance.fakeTimers!.useFakeTimers();

const timer1 = env1.global.setTimeout(() => {}, 0);
const timer2 = env1.global.setInterval(() => {}, 0);
const timer1 = instance.global.setTimeout(() => {}, 0);
const timer2 = instance.global.setInterval(() => {}, 0);

[timer1, timer2].forEach(timer => {
expect(typeof timer).toBe("number");
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.build.json
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig",
"exclude": ["src/**/__mocks__/*", "src/**/__tests__/*"]
}
3 changes: 1 addition & 2 deletions tsconfig.json
Expand Up @@ -12,6 +12,5 @@
"strict": true,
"target": "es5"
},
"include": ["src/**/*"],
"exclude": ["src/**/__mocks__/*", "src/**/__tests__/*"]
"include": ["src/**/*"]
}

0 comments on commit b4e5264

Please sign in to comment.