@testing-library/user-event 10.3.2 → 10.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,67 +1,66 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "10.3.2",
4
- "description": "Simulate user events for react-testing-library",
3
+ "version": "10.4.0",
4
+ "description": "Fire events the same way the user does",
5
+ "main": "dist/index.js",
6
+ "typings": "typings/index.d.ts",
5
7
  "keywords": [
6
8
  "react-testing-library",
7
9
  "dom-testing-library",
8
10
  "react",
9
11
  "testing"
10
12
  ],
11
- "main": "dist/index.js",
12
- "typings": "typings/index.d.ts",
13
- "scripts": {
14
- "test": "jest",
15
- "test:coverage": "npm t -- --coverage",
16
- "codecov": "codecov",
17
- "build": "babel src -d dist",
18
- "semantic-release": "semantic-release",
19
- "travis-deploy-once": "travis-deploy-once",
20
- "cm": "npx git-cz",
21
- "contributors:add": "all-contributors add",
22
- "contributors:generate": "all-contributors generate"
13
+ "author": "Giorgio Polvara <polvara@gmail.com>",
14
+ "license": "MIT",
15
+ "engines": {
16
+ "node": ">=10",
17
+ "npm": ">=6"
23
18
  },
24
19
  "repository": {
25
20
  "type": "git",
26
- "url": "https://github.com/testing-library/user-event.git"
21
+ "url": "https://github.com/testing-library/user-event"
27
22
  },
28
- "author": "Giorgio Polvara <polvara@gmail.com>",
29
- "license": "MIT",
30
23
  "bugs": {
31
24
  "url": "https://github.com/testing-library/user-event/issues"
32
25
  },
33
26
  "homepage": "https://github.com/testing-library/user-event#readme",
27
+ "files": [
28
+ "dist",
29
+ "typings"
30
+ ],
31
+ "scripts": {
32
+ "build": "kcd-scripts build",
33
+ "lint": "kcd-scripts lint",
34
+ "setup": "npm install && npm run validate -s",
35
+ "test": "kcd-scripts test",
36
+ "test:update": "npm test -- --updateSnapshot --coverage",
37
+ "validate": "kcd-scripts validate"
38
+ },
39
+ "dependencies": {
40
+ "@babel/runtime": "^7.9.6"
41
+ },
34
42
  "devDependencies": {
35
- "@babel/cli": "^7.8.4",
36
- "@babel/core": "^7.9.0",
37
- "@babel/preset-env": "^7.9.5",
38
- "@babel/preset-react": "^7.9.4",
39
- "@testing-library/dom": "^7.2.1",
40
- "@testing-library/jest-dom": "^5.5.0",
41
- "@testing-library/react": "^9.4.0",
42
- "@testing-library/vue": "^4.1.0",
43
- "all-contributors-cli": "^6.14.1",
44
- "babel-core": "7.0.0-bridge.0",
45
- "babel-jest": "^25.3.0",
46
- "codecov": "^3.6.5",
47
- "husky": "^4.2.5",
48
- "jest": "24.9.0",
49
- "lint-staged": "^10.1.3",
50
- "prettier": "^2.0.4",
43
+ "@testing-library/dom": "^7.5.7",
44
+ "@testing-library/jest-dom": "^5.8.0",
45
+ "@testing-library/react": "^10.0.4",
46
+ "kcd-scripts": "^6.0.1",
51
47
  "react": "^16.13.1",
52
- "react-dom": "^16.13.1",
53
- "regenerator-runtime": "^0.13.5",
54
- "semantic-release": "^17.0.4",
55
- "travis-deploy-once": "5.0.11",
56
- "vue": "^2.6.11",
57
- "vue-template-compiler": "^2.6.11"
48
+ "react-dom": "^16.13.1"
58
49
  },
59
50
  "peerDependencies": {
60
51
  "@testing-library/dom": ">=5"
61
52
  },
62
- "husky": {
63
- "hooks": {
64
- "pre-commit": "lint-staged"
53
+ "eslintConfig": {
54
+ "extends": "./node_modules/kcd-scripts/eslint.js",
55
+ "rules": {
56
+ "jsx-a11y/click-events-have-key-events": "off",
57
+ "jsx-a11y/tabindex-no-positive": "off",
58
+ "no-return-assign": "off"
65
59
  }
66
- }
60
+ },
61
+ "eslintIgnore": [
62
+ "node_modules",
63
+ "coverage",
64
+ "dist"
65
+ ]
67
66
  }
@@ -1,39 +1,43 @@
1
1
  // Definitions by: Wu Haotian <https://github.com/whtsky>
2
2
  export interface IUserOptions {
3
- allAtOnce?: boolean;
4
- delay?: number;
3
+ allAtOnce?: boolean
4
+ delay?: number
5
5
  }
6
6
 
7
7
  export interface ITabUserOptions {
8
- shift?: boolean;
9
- focusTrap?: Document | Element;
8
+ shift?: boolean
9
+ focusTrap?: Document | Element
10
10
  }
11
11
 
12
- export type TargetElement = Element | Window;
12
+ export type TargetElement = Element | Window
13
13
 
14
- export type FilesArgument = File | File[];
14
+ export type FilesArgument = File | File[]
15
15
 
16
16
  export type UploadInitArgument = {
17
- clickInit?: MouseEventInit;
18
- changeInit?: Event;
19
- };
17
+ clickInit?: MouseEventInit
18
+ changeInit?: Event
19
+ }
20
20
 
21
21
  declare const userEvent: {
22
- clear: (element: TargetElement) => void;
23
- click: (element: TargetElement, init?: MouseEventInit) => void;
24
- dblClick: (element: TargetElement) => void;
25
- selectOptions: (element: TargetElement, values: string | string[]) => void;
22
+ clear: (element: TargetElement) => void
23
+ click: (element: TargetElement, init?: MouseEventInit) => void
24
+ dblClick: (element: TargetElement, init?: MouseEventInit) => void
25
+ selectOptions: (
26
+ element: TargetElement,
27
+ values: string | string[] | HTMLElement | HTMLElement[],
28
+ init?: MouseEventInit,
29
+ ) => void
26
30
  upload: (
27
31
  element: TargetElement,
28
32
  files: FilesArgument,
29
- init?: UploadInitArgument
30
- ) => void;
33
+ init?: UploadInitArgument,
34
+ ) => void
31
35
  type: (
32
36
  element: TargetElement,
33
37
  text: string,
34
- userOpts?: IUserOptions
35
- ) => Promise<void>;
36
- tab: (userOpts?: ITabUserOptions) => void;
37
- };
38
+ userOpts?: IUserOptions,
39
+ ) => Promise<void>
40
+ tab: (userOpts?: ITabUserOptions) => void
41
+ }
38
42
 
39
- export default userEvent;
43
+ export default userEvent
@@ -1,311 +0,0 @@
1
- {
2
- "projectName": "user-event",
3
- "projectOwner": "testing-library",
4
- "repoType": "github",
5
- "repoHost": "https://github.com",
6
- "files": [
7
- "README.md"
8
- ],
9
- "imageSize": 100,
10
- "commit": true,
11
- "contributors": [
12
- {
13
- "login": "Gpx",
14
- "name": "Giorgio Polvara",
15
- "avatar_url": "https://avatars0.githubusercontent.com/u/767959?v=4",
16
- "profile": "https://twitter.com/Gpx",
17
- "contributions": [
18
- "bug",
19
- "code",
20
- "doc",
21
- "ideas",
22
- "infra",
23
- "review",
24
- "test"
25
- ]
26
- },
27
- {
28
- "login": "weyert",
29
- "name": "Weyert de Boer",
30
- "avatar_url": "https://avatars3.githubusercontent.com/u/7049?v=4",
31
- "profile": "https://github.com/weyert",
32
- "contributions": [
33
- "code",
34
- "test"
35
- ]
36
- },
37
- {
38
- "login": "twhitbeck",
39
- "name": "Tim Whitbeck",
40
- "avatar_url": "https://avatars2.githubusercontent.com/u/762471?v=4",
41
- "profile": "https://github.com/twhitbeck",
42
- "contributions": [
43
- "bug",
44
- "code"
45
- ]
46
- },
47
- {
48
- "login": "MichaelDeBoey",
49
- "name": "Michaël De Boey",
50
- "avatar_url": "https://avatars3.githubusercontent.com/u/6643991?v=4",
51
- "profile": "https://michaeldeboey.be",
52
- "contributions": [
53
- "doc"
54
- ]
55
- },
56
- {
57
- "login": "michaellasky",
58
- "name": "Michael Lasky",
59
- "avatar_url": "https://avatars2.githubusercontent.com/u/6646599?v=4",
60
- "profile": "https://github.com/michaellasky",
61
- "contributions": [
62
- "code",
63
- "doc",
64
- "ideas"
65
- ]
66
- },
67
- {
68
- "login": "shomalgan",
69
- "name": "Ahmad Esmaeilzadeh",
70
- "avatar_url": "https://avatars0.githubusercontent.com/u/2883620?v=4",
71
- "profile": "https://github.com/shomalgan",
72
- "contributions": [
73
- "doc"
74
- ]
75
- },
76
- {
77
- "login": "calebeby",
78
- "name": "Caleb Eby",
79
- "avatar_url": "https://avatars1.githubusercontent.com/u/13206945?v=4",
80
- "profile": "https://calebeby.ml",
81
- "contributions": [
82
- "code",
83
- "bug",
84
- "review"
85
- ]
86
- },
87
- {
88
- "login": "afontcu",
89
- "name": "Adrià Fontcuberta",
90
- "avatar_url": "https://avatars0.githubusercontent.com/u/9197791?v=4",
91
- "profile": "https://afontcu.dev",
92
- "contributions": [
93
- "bug",
94
- "test",
95
- "code"
96
- ]
97
- },
98
- {
99
- "login": "skywickenden",
100
- "name": "Sky Wickenden",
101
- "avatar_url": "https://avatars2.githubusercontent.com/u/4930551?v=4",
102
- "profile": "https://github.com/skywickenden",
103
- "contributions": [
104
- "bug",
105
- "code"
106
- ]
107
- },
108
- {
109
- "login": "bogdanbodnar",
110
- "name": "Bodnar Bogdan",
111
- "avatar_url": "https://avatars2.githubusercontent.com/u/9034868?v=4",
112
- "profile": "https://github.com/bogdanbodnar",
113
- "contributions": [
114
- "bug",
115
- "code"
116
- ]
117
- },
118
- {
119
- "login": "zperrault",
120
- "name": "Zach Perrault",
121
- "avatar_url": "https://avatars0.githubusercontent.com/u/1699281?v=4",
122
- "profile": "https://zach.website",
123
- "contributions": [
124
- "doc"
125
- ]
126
- },
127
- {
128
- "login": "FLGMwt",
129
- "name": "Ryan Stelly",
130
- "avatar_url": "https://avatars1.githubusercontent.com/u/4138357?v=4",
131
- "profile": "https://twitter.com/ryanastelly",
132
- "contributions": [
133
- "doc"
134
- ]
135
- },
136
- {
137
- "login": "benmonro",
138
- "name": "Ben Monro",
139
- "avatar_url": "https://avatars3.githubusercontent.com/u/399236?v=4",
140
- "profile": "https://github.com/benmonro",
141
- "contributions": [
142
- "code"
143
- ]
144
- },
145
- {
146
- "login": "GentlemanHal",
147
- "name": "Christopher Martin",
148
- "avatar_url": "https://avatars2.githubusercontent.com/u/415521?v=4",
149
- "profile": "https://github.com/GentlemanHal",
150
- "contributions": [
151
- "code"
152
- ]
153
- },
154
- {
155
- "login": "YuanchengWu",
156
- "name": "Yuancheng Wu",
157
- "avatar_url": "https://avatars0.githubusercontent.com/u/32252769?v=4",
158
- "profile": "http://fullgallop.me",
159
- "contributions": [
160
- "review"
161
- ]
162
- },
163
- {
164
- "login": "maheshjag",
165
- "name": "MJ",
166
- "avatar_url": "https://avatars0.githubusercontent.com/u/1705603?v=4",
167
- "profile": "https://github.com/maheshjag",
168
- "contributions": [
169
- "doc"
170
- ]
171
- },
172
- {
173
- "login": "jmcriffey",
174
- "name": "Jeff McRiffey",
175
- "avatar_url": "https://avatars0.githubusercontent.com/u/2831294?v=4",
176
- "profile": "https://github.com/jmcriffey",
177
- "contributions": [
178
- "code",
179
- "test"
180
- ]
181
- },
182
- {
183
- "login": "kandros",
184
- "name": "Jaga Santagostino",
185
- "avatar_url": "https://avatars0.githubusercontent.com/u/4562878?v=4",
186
- "profile": "http://jagascript.com",
187
- "contributions": [
188
- "code",
189
- "test"
190
- ]
191
- },
192
- {
193
- "login": "jordyvandomselaar",
194
- "name": "jordyvandomselaar",
195
- "avatar_url": "https://avatars3.githubusercontent.com/u/12712484?v=4",
196
- "profile": "http://jordy.app",
197
- "contributions": [
198
- "code",
199
- "test"
200
- ]
201
- },
202
- {
203
- "login": "ilyamkin",
204
- "name": "Ilya Lyamkin",
205
- "avatar_url": "https://avatars2.githubusercontent.com/u/3854930?v=4",
206
- "profile": "https://lyamkin.com",
207
- "contributions": [
208
- "code",
209
- "test"
210
- ]
211
- },
212
- {
213
- "login": "klujanrosas",
214
- "name": "Kenneth Luján Rosas",
215
- "avatar_url": "https://avatars2.githubusercontent.com/u/4474353?v=4",
216
- "profile": "http://todofullstack.com",
217
- "contributions": [
218
- "code",
219
- "test"
220
- ]
221
- },
222
- {
223
- "login": "jsmapr1",
224
- "name": "Joe Morgan",
225
- "avatar_url": "https://avatars1.githubusercontent.com/u/2388943?v=4",
226
- "profile": "http://thejoemorgan.com",
227
- "contributions": [
228
- "code"
229
- ]
230
- },
231
- {
232
- "login": "wachunga",
233
- "name": "David Hirtle",
234
- "avatar_url": "https://avatars0.githubusercontent.com/u/438545?v=4",
235
- "profile": "https://twitter.com/wachunga",
236
- "contributions": [
237
- "code"
238
- ]
239
- },
240
- {
241
- "login": "bdh1011",
242
- "name": "whiteUnicorn",
243
- "avatar_url": "https://avatars2.githubusercontent.com/u/8446067?v=4",
244
- "profile": "https://github.com/bdh1011",
245
- "contributions": [
246
- "code"
247
- ]
248
- },
249
- {
250
- "login": "Meemaw",
251
- "name": "Matej Šnuderl",
252
- "avatar_url": "https://avatars3.githubusercontent.com/u/8524109?v=4",
253
- "profile": "https://www.matej.snuderl.si/",
254
- "contributions": [
255
- "review"
256
- ]
257
- },
258
- {
259
- "login": "pomber",
260
- "name": "Rodrigo Pombo",
261
- "avatar_url": "https://avatars1.githubusercontent.com/u/1911623?v=4",
262
- "profile": "https://pomb.us",
263
- "contributions": [
264
- "code"
265
- ]
266
- },
267
- {
268
- "login": "Raynos",
269
- "name": "Jake Verbaten",
270
- "avatar_url": "https://avatars3.githubusercontent.com/u/479538?v=4",
271
- "profile": "http://github.com/Raynos",
272
- "contributions": [
273
- "code"
274
- ]
275
- },
276
- {
277
- "login": "skovy",
278
- "name": "Spencer Miskoviak",
279
- "avatar_url": "https://avatars1.githubusercontent.com/u/5247455?v=4",
280
- "profile": "https://skovy.dev",
281
- "contributions": [
282
- "doc"
283
- ]
284
- },
285
- {
286
- "login": "vadimshvetsov",
287
- "name": "Vadim Shvetsov",
288
- "avatar_url": "https://avatars2.githubusercontent.com/u/16336572?v=4",
289
- "profile": "https://proling.ru/",
290
- "contributions": [
291
- "ideas",
292
- "code",
293
- "test"
294
- ]
295
- },
296
- {
297
- "login": "9still",
298
- "name": "Greg Shtilman",
299
- "avatar_url": "https://avatars0.githubusercontent.com/u/4924760?v=4",
300
- "profile": "https://github.com/9still",
301
- "contributions": [
302
- "code",
303
- "test",
304
- "bug"
305
- ]
306
- }
307
- ],
308
- "commitConvention": "none",
309
- "skipCi": false,
310
- "contributorsPerLine": 7
311
- }
package/.babelrc DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "node": "8",
8
- },
9
- },
10
- ],
11
- "@babel/preset-react"
12
- ]
13
- }
package/.gitattributes DELETED
@@ -1 +0,0 @@
1
- text=auto
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- v13.8.0
package/.prettierrc.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- proseWrap: "always"
3
- };
package/.travis.yml DELETED
@@ -1,30 +0,0 @@
1
- env:
2
- global:
3
- - CC_TEST_REPORTER_ID=432df2a7d2692b54e9c072feb2c8cec8cd943456c14800c18445b6e65f709a3c
4
- - CODECOV_TOKEN="a0f80db0-4517-4d00-a6e6-eaf8a7089079"
5
- language: node_js
6
- cache:
7
- directories:
8
- - ~/.npm
9
- notifications:
10
- email: false
11
- node_js:
12
- - '13'
13
- - '12'
14
- - '10'
15
- before_script:
16
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
17
- - chmod +x ./cc-test-reporter
18
- - ./cc-test-reporter before-build
19
- after_script:
20
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
21
- script:
22
- - npm run test:coverage
23
- after_success:
24
- - npm run codecov
25
- - npm run build
26
- - rm ./cc-test-reporter
27
- - npm run travis-deploy-once "npm run semantic-release"
28
- branches:
29
- except:
30
- - /^v\d+\.\d+\.\d+$/
@@ -1,94 +0,0 @@
1
- import React from "react";
2
- import { cleanup, render } from "@testing-library/react";
3
- import "@testing-library/jest-dom/extend-expect";
4
- import userEvent from "../../src";
5
-
6
- afterEach(cleanup);
7
-
8
- describe("userEvent.clear", () => {
9
- it.each(["input", "textarea"])("should clear text in <%s>", (type) => {
10
- const onChange = jest.fn();
11
- const { getByTestId } = render(
12
- React.createElement(type, {
13
- "data-testid": "input",
14
- onChange: onChange,
15
- value: "Hello, world!",
16
- })
17
- );
18
-
19
- const input = getByTestId("input");
20
- userEvent.clear(input);
21
- expect(input.value).toBe("");
22
- });
23
-
24
- it.each(["input", "textarea"])(
25
- "should not clear when <%s> is disabled",
26
- (type) => {
27
- const text = "Hello, world!";
28
- const onChange = jest.fn();
29
- const { getByTestId } = render(
30
- React.createElement(type, {
31
- "data-testid": "input",
32
- onChange: onChange,
33
- value: text,
34
- disabled: true,
35
- })
36
- );
37
-
38
- const input = getByTestId("input");
39
- userEvent.clear(input);
40
- expect(input).toHaveProperty("value", text);
41
- }
42
- );
43
-
44
- it.each(["input", "textarea"])(
45
- "should not clear when <%s> is readOnly",
46
- (type) => {
47
- const onChange = jest.fn();
48
- const onKeyDown = jest.fn();
49
- const onKeyUp = jest.fn();
50
-
51
- const text = "Hello, world!";
52
- const { getByTestId } = render(
53
- React.createElement(type, {
54
- "data-testid": "input",
55
- onChange,
56
- onKeyDown,
57
- onKeyUp,
58
- value: text,
59
- readOnly: true,
60
- })
61
- );
62
-
63
- const input = getByTestId("input");
64
- userEvent.clear(input);
65
- expect(onKeyDown).toHaveBeenCalledTimes(1);
66
- expect(onKeyUp).toHaveBeenCalledTimes(1);
67
- expect(input).toHaveProperty("value", text);
68
- }
69
- );
70
-
71
- ["email", "password", "number", "text"].forEach((type) => {
72
- it.each(["input", "textarea"])(
73
- `should clear when <%s> is of type="${type}"`,
74
- (inputType) => {
75
- const value = "12345";
76
- const placeholder = "Enter password";
77
-
78
- const element = React.createElement(inputType, {
79
- value,
80
- placeholder,
81
- type,
82
- onChange: jest.fn(),
83
- });
84
-
85
- const { getByPlaceholderText } = render(element);
86
-
87
- const input = getByPlaceholderText(placeholder);
88
- expect(input.value).toBe(value);
89
- userEvent.clear(input);
90
- expect(input.value).toBe("");
91
- }
92
- );
93
- });
94
- });