Skip to content

Commit

Permalink
Merge pull request #1523 from Adslot/react18
Browse files Browse the repository at this point in the history
React18
  • Loading branch information
Kai GAO authored Jun 15, 2023
2 parents 8e03fae + d4edfd1 commit 9f30149
Show file tree
Hide file tree
Showing 137 changed files with 7,801 additions and 8,485 deletions.
21 changes: 18 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
{
"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.js?(x)"],
"extends": ["plugin:jest/recommended", "plugin:jest-dom/recommended", "plugin:testing-library/react"],
"rules": {
"jest/expect-expect": "error",
"jest/no-commented-out-tests": "off"
}
}
]
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ window.Perf = Perf;
- Interact the component in the way that feels slow.
- Run `Perf.stop()` to stop recording.
- Run `Perf.printWasted()` to see the nodes that are re–rendering but do not change the DOM.
- Use fastStatelessWrapper to wrap this component, passing in the properties to check.
- Re-test to make sure you're improving performance.

## Design tokens
Expand Down
6 changes: 3 additions & 3 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
coverage:
round: down
precision: 2
range: 98...100
range: 95...100
ignore:
- 'src/components/**/*.spec.*'
- 'src/components/**/mocks.*'
- 'src/**/*.spec.*'
- 'src/**/mocks.*'
status:
project:
default:
Expand Down
45 changes: 35 additions & 10 deletions config/testSetup.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
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(),
}),
});

Object.defineProperty(window, 'scrollTo', { value: () => {}, writable: true });
window.ResizeObserver = class ResizeObserver {
observe = jest.fn();
unobserve = jest.fn();
disconnect = 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();
});
Loading

0 comments on commit 9f30149

Please sign in to comment.