Skip to content

Commit c726659

Browse files
committed
test: fix test case issue.
1 parent c08032b commit c726659

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

core/src/__test__/index.test.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* eslint-disable jest/no-conditional-expect */
21
import React, { useEffect, useRef } from 'react';
32
import TestRenderer from 'react-test-renderer';
4-
import { fireEvent, render, screen } from '@testing-library/react';
3+
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
54
import '@testing-library/jest-dom';
65
import userEvent from '@testing-library/user-event';
76
import TextareaCodeEditor from '../';
@@ -180,13 +179,15 @@ it('TextareaCodeEditor onKeyDown Tab Input', async () => {
180179
const elmTextarea = screen.getByDisplayValue('This is a bad example');
181180
(elmTextarea as HTMLTextAreaElement).setSelectionRange(1, 1);
182181
elmTextarea.focus();
183-
await userEvent.keyboard('a');
184-
expect(onKeyDown).toHaveBeenCalledTimes(1);
185-
// expect(onKeyDown.mock.calls[0][0]).toHaveProperty('keyCode', 97);
182+
await waitFor(async () => {
183+
await userEvent.keyboard('a');
184+
expect(onKeyDown).toHaveBeenCalledTimes(1);
185+
// expect(onKeyDown.mock.calls[0][0]).toHaveProperty('keyCode', 97);
186+
await userEvent.keyboard('[Enter]');
187+
expect(onKeyDown).toHaveBeenCalledTimes(2);
188+
// expect(onKeyDown.mock.calls[1][0]).toHaveProperty('keyCode', 13);
189+
});
186190

187-
await userEvent.keyboard('[Enter]');
188-
expect(onKeyDown).toHaveBeenCalledTimes(2);
189-
// expect(onKeyDown.mock.calls[1][0]).toHaveProperty('keyCode', 13);
190191
elmTextarea.focus();
191192
expect(elmTextarea).toHaveValue('Ta\nhis is a bad example');
192193

package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"doc": "lerna exec --scope website -- npm run build",
1111
"bundle": "lerna exec --scope @uiw/react-textarea-code-editor -- ncc build src/index.tsx --target web --filename editor",
1212
"bundle:min": "lerna exec --scope @uiw/react-textarea-code-editor -- ncc build src/index.tsx --target web --filename editor --minify",
13-
"test": "lerna exec --scope @uiw/react-textarea-code-editor -- tsbb test --env=jsdom",
14-
"coverage": "lerna exec --scope @uiw/react-textarea-code-editor -- tsbb test --env=jsdom --coverage --bail",
13+
"test": "lerna exec --scope @uiw/react-textarea-code-editor -- tsbb test",
14+
"coverage": "lerna exec --scope @uiw/react-textarea-code-editor -- tsbb test --coverage --bail",
1515
"prepare": "husky install",
1616
"publish": "lerna publish from-package --yes --no-verify-access",
1717
"version": "lerna version --exact --force-publish --no-push --no-git-tag-version",
@@ -35,17 +35,13 @@
3535
"@kkt/scope-plugin-options": "^7.5.2",
3636
"@kkt/less-modules": "^7.5.2",
3737
"@kkt/ncc": "^1.0.14",
38-
"compile-less-cli": "^1.8.14",
38+
"compile-less-cli": "^1.9.0",
3939
"husky": "^8.0.3",
40-
"jest": "^29.5.0",
41-
"jest-watch-typeahead": "^2.2.2",
42-
"jest-environment-jsdom": "~29.5.0",
43-
"jest-environment-node": "^29.5.0",
4440
"kkt": "^7.5.2",
4541
"lint-staged": "^14.0.0",
4642
"lerna": "^7.1.3",
4743
"prettier": "^3.0.0",
4844
"react-test-renderer": "^18.2.0",
49-
"tsbb": "^4.1.14"
45+
"tsbb": "^4.2.1"
5046
}
5147
}

www/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"dependencies": {
1111
"@uiw/react-textarea-code-editor": "2.1.7",
12-
"@uiw/react-markdown-preview-example": "^1.3.1",
12+
"@uiw/react-markdown-preview-example": "^1.5.7",
1313
"@uiw/react-loader": "^4.21.14",
1414
"styled-components": "^6.0.5",
1515
"code-example": "^3.3.6",

0 commit comments

Comments
 (0)