Skip to content

Commit

Permalink
feat: 兼容rsuite@5 Modal (#14)
Browse files Browse the repository at this point in the history
* update: 兼容rsuite@5 Modal

* update:更新rsuite版本

* update:兼容低版本rsuite

* update: test case

* fix: rsuite@3 Compatibility

* update: rsuite@5

* update: 测试兼容rsuite@4/@5

* bugfixed: 修复环境变量注入

Co-authored-by: sun <qiang.sun@mail.hypers.com>
  • Loading branch information
MarvelSQ and sun authored Mar 22, 2021
1 parent b1b2ea9 commit 3a47102
Show file tree
Hide file tree
Showing 7 changed files with 356 additions and 54 deletions.
4 changes: 1 addition & 3 deletions __tests__/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ let okButton;
async function openAlert(message, options) {
await closeAlert();
alert(message, options);
modal = (await screen.findAllByRole('dialog')).find((div) =>
div.classList.contains('rs-modal')
);
modal = (await screen.findByText(message)).closest('.rs-modal');
okButton = modal.querySelector('.rs-btn-primary');
}

Expand Down
4 changes: 1 addition & 3 deletions __tests__/confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ describe('resolves correctly', () => {

beforeEach(async () => {
promise = confirm('Message');
modal = (await screen.findAllByRole('dialog')).find((div) =>
div.classList.contains('rs-modal')
);
modal = (await screen.findByText('Message')).closest('.rs-modal');
okButton = modal.querySelector('.rs-btn-primary');
cancelButton = modal.querySelector('.rs-btn-default');
});
Expand Down
4 changes: 1 addition & 3 deletions __tests__/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ describe('resolves correctly', () => {
const inputValue = 'Input value';
beforeEach(async () => {
promise = prompt('Message');
modal = (await screen.findAllByRole('dialog')).find((div) =>
div.classList.contains('rs-modal')
);
modal = (await screen.findByText('Message')).closest('.rs-modal');
input = modal.querySelector('input');
userEvent.type(input, inputValue);
});
Expand Down
26 changes: 26 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
import '@testing-library/jest-dom';

if (process.env.RSUITE === '5') {
jest.mock(
'date-fns/_lib/toInteger/index.js',
() => {
return jest.requireActual('date-fns2/_lib/toInteger/index.js');
},
{ virtual: true }
);

jest.mock(
'date-fns/_lib/cloneObject',
() => {
return jest.requireActual('date-fns2/_lib/cloneObject');
},
{ virtual: true }
);

jest.mock('rsuite', () => {
return jest.requireActual('rsuite5');
});
} else {
jest.mock('rsuite', () => {
return jest.requireActual('rsuite4');
});
}
Loading

0 comments on commit 3a47102

Please sign in to comment.