-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update tests and fix proptypes & invariants
- Loading branch information
1 parent
eb279d3
commit 611e8de
Showing
109 changed files
with
7,122 additions
and
6,814 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
{ | ||
"root": true, | ||
"plugins": ["jest-dom"], | ||
"extends": ["adslot", "plugin:jest-dom/recommended", "plugin:import/typescript"], | ||
"extends": ["adslot", "plugin:import/typescript"], | ||
"settings": { | ||
"lodash": { | ||
"version": 4 | ||
}, | ||
"import/resolver": { | ||
"alias": { | ||
"map": [["testing", "./config/testing"]] | ||
} | ||
} | ||
}, | ||
"rules": { | ||
"no-console": ["error", { "allow": ["warn", "error"] }], | ||
"@typescript-eslint/no-explicit-any": "off" | ||
} | ||
}, | ||
|
||
"overrides": [ | ||
{ | ||
"files": ["**/?(*.)+(spec|test).js?(x)"], | ||
"extends": ["plugin:jest-dom/recommended", "plugin:testing-library/react"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,54 @@ | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import '@testing-library/jest-dom'; | ||
|
||
window.matchMedia = jest.fn().mockImplementation((query) => { | ||
return { | ||
// for slick-carousel, date picker | ||
Object.defineProperty(window, 'matchMedia', { | ||
writable: true, | ||
value: (query) => ({ | ||
matches: false, | ||
media: query, | ||
onchange: null, | ||
addListener: jest.fn(), | ||
removeListener: jest.fn(), | ||
}; | ||
addEventListener: jest.fn(), | ||
removeEventListener: jest.fn(), | ||
dispatchEvent: jest.fn(), | ||
}), | ||
}); | ||
|
||
// for RichTextEditor | ||
Object.defineProperty(window, 'scrollTo', { | ||
writable: true, | ||
value: jest.fn(), | ||
}); | ||
|
||
Object.defineProperty(HTMLElement.prototype, 'scrollIntoView', { | ||
writable: true, | ||
value: jest.fn(), | ||
}); | ||
|
||
// for Paragraph | ||
Object.defineProperty(window, 'ResizeObserver', { | ||
writable: true, | ||
value: class ResizeObserver { | ||
observe = jest.fn(); | ||
unobserve = jest.fn(); | ||
disconnect = jest.fn(); | ||
}, | ||
}); | ||
|
||
// for cropperjs | ||
beforeEach(() => { | ||
jest.spyOn(XMLHttpRequest.prototype, 'open').mockReturnValue(); | ||
jest.spyOn(XMLHttpRequest.prototype, 'send').mockReturnValue(); | ||
}); | ||
|
||
Object.defineProperty(window, 'scrollTo', { value: () => {}, writable: true }); | ||
window.ResizeObserver = class ResizeObserver { | ||
observe = jest.fn(); | ||
unobserve = jest.fn(); | ||
disconnect = jest.fn(); | ||
}; | ||
// auto mock invariant to avoid console error | ||
jest.mock('../src/invariant', () => { | ||
const originalModule = jest.requireActual('../src/invariant'); | ||
|
||
return { | ||
__esModule: true, | ||
...originalModule, | ||
default: jest.fn(), | ||
}; | ||
}); |
Oops, something went wrong.