Skip to content

Commit

Permalink
fixed bugs from upgrading enzyme
Browse files Browse the repository at this point in the history
  • Loading branch information
dfee committed Mar 19, 2019
1 parent 88e62cc commit d5e33da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
},
},
moduleDirectories: ["node_modules", "<rootDir>"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"],
moduleNameMapper: {
"\\.(css|less|s(c|a)ss)$": "<rootDir>/src/__mocks__/style.ts",
"@/(.*)": "<rootDir>/$1",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/testing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const withWindow = contextManager(
// tslint:disable:no-any
({ value }: { value?: undefined } = {}) => {
const window = (global as any).window;
delete (global as any).window;
// delete (global as any).window;

if (value !== undefined) {
(global as any).window = value;
Expand Down
8 changes: 6 additions & 2 deletions src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ describe("Utils", () => {
});

it("should return false without window (SSR)", () => {
withWindow({}, () => {
const initialWindow = window;
try {
delete (global as any).window; // tslint:disable-line:no-any
expect(() => window).toThrow(
new ReferenceError("window is not defined"),
);
expect(canUseDOM()).toBe(false);
});
} catch {
(global as any).window = initialWindow; // tslint:disable-line:no-any
}
});

it("should return false without document", () => {
Expand Down

0 comments on commit d5e33da

Please sign in to comment.