Skip to content

Commit df5c4cb

Browse files
Remove v2 tests (adobe#2641)
* Remove V2 Tests * fix a few issues Co-authored-by: Danni <[email protected]>
1 parent bc86137 commit df5c4cb

28 files changed

+152
-599
lines changed

.eslintrc.js

-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ module.exports = {
280280
{
281281
ignore: [
282282
'@adobe/spectrum-css-temp',
283-
'@react/react-spectrum',
284283
'@spectrum-icons/ui',
285284
'@spectrum-icons/workflow',
286285
'@spectrum-icons/illustrations'

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ dist
1111
.package-lock.json
1212
.cache
1313
.parcel-cache
14-
packages/dev/v2-test-deps
1514

1615
dist
1716
public

Makefile

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ PATH := ./node_modules/.bin:$(PATH)
55

66
all: node_modules
77

8-
adobe_setup:
9-
mkdir packages/dev/v2-test-deps
10-
cp scripts/v2-package.json packages/dev/v2-test-deps/package.json
11-
128
node_modules: package.json
139
yarn install
1410
touch $@

jest.config.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
// For a detailed explanation regarding each configuration property, visit:
1414
// https://jestjs.io/docs/en/configuration.html
1515

16-
// Mock v2 if not installed
17-
let mocks = {};
18-
try {
19-
require.resolve('@react/react-spectrum/Button');
20-
} catch (err) {
21-
mocks['^@react/.*'] = 'identity-obj-proxy';
22-
}
23-
2416
module.exports = {
2517
// All imported modules in your tests should be mocked automatically
2618
// automock: false,
@@ -100,8 +92,7 @@ module.exports = {
10092
// A map from regular expressions to module names that allow to stub out resources with a single module
10193
moduleNameMapper: {
10294
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
103-
'\\.(css|styl)$': 'identity-obj-proxy',
104-
...mocks
95+
'\\.(css|styl)$': 'identity-obj-proxy'
10596
},
10697

10798
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader

packages/@react-spectrum/button/test/ActionButton.test.js

-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {ActionButton} from '../';
1414
import React from 'react';
1515
import {render} from '@testing-library/react';
1616
import {triggerPress} from '@react-spectrum/test-utils';
17-
import V2Button from '@react/react-spectrum/Button';
1817

1918
describe('ActionButton', function () {
2019
let onPressSpy = jest.fn();
@@ -26,7 +25,6 @@ describe('ActionButton', function () {
2625
it.each`
2726
Name | Component | props
2827
${'ActionButton'} | ${ActionButton} | ${{onPress: onPressSpy}}
29-
${'V2Button'} | ${V2Button} | ${{variant: 'action', onClick: onPressSpy}}
3028
`('$Name handles defaults', function ({Component, props}) {
3129
let {getByRole} = render(<Component {...props}>Click Me</Component>);
3230

@@ -40,7 +38,6 @@ describe('ActionButton', function () {
4038
it.each`
4139
Name | Component | props
4240
${'ActionButton'} | ${ActionButton} | ${{}}
43-
${'V2Button'} | ${V2Button} | ${{variant: 'action'}}
4441
`('$Name allows custom props to be passed through to the button', function ({Component, props}) {
4542
let {getByRole} = render(<Component {...props} data-foo="bar">Click Me</Component>);
4643

packages/@react-spectrum/button/test/Button.test.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {ActionButton, Button, ClearButton, LogicButton} from '../';
1414
import {fireEvent, render} from '@testing-library/react';
1515
import React from 'react';
1616
import {triggerPress} from '@react-spectrum/test-utils';
17-
import V2Button from '@react/react-spectrum/Button';
1817

1918
/**
2019
* Logic Button has no tests outside of this file because functionally it is identical
@@ -34,7 +33,6 @@ describe('Button', function () {
3433
${'ActionButton'} | ${ActionButton}| ${{onPress: onPressSpy}}
3534
${'Button'} | ${Button} | ${{onPress: onPressSpy}}
3635
${'LogicButton'} | ${LogicButton} | ${{onPress: onPressSpy}}
37-
${'V2Button'} | ${V2Button} | ${{onClick: onPressSpy}}
3836
`('$Name handles defaults', function ({Component, props}) {
3937
let {getByRole, getByText} = render(<Component {...props}>Click Me</Component>);
4038

@@ -52,7 +50,6 @@ describe('Button', function () {
5250
${'Button'} | ${Button}
5351
${'ClearButton'} | ${ClearButton}
5452
${'LogicButton'} | ${LogicButton}
55-
${'V2Button'} | ${V2Button}
5653
`('$Name allows custom props to be passed through to the button', function ({Component}) {
5754
let {getByRole} = render(<Component data-foo="bar">Click Me</Component>);
5855

@@ -66,7 +63,6 @@ describe('Button', function () {
6663
${'Button'} | ${Button}
6764
${'ClearButton'} | ${ClearButton}
6865
${'LogicButton'} | ${LogicButton}
69-
${'V2Button'} | ${V2Button}
7066
`('$Name supports aria-label', function ({Component}) {
7167
let {getByRole} = render(<Component aria-label="Test" />);
7268

@@ -80,7 +76,6 @@ describe('Button', function () {
8076
${'Button'} | ${Button}
8177
${'ClearButton'} | ${ClearButton}
8278
${'LogicButton'} | ${LogicButton}
83-
${'V2Button'} | ${V2Button}
8479
`('$Name supports aria-labelledby', function ({Component}) {
8580
let {getByRole} = render(
8681
<>
@@ -99,7 +94,6 @@ describe('Button', function () {
9994
${'Button'} | ${Button}
10095
${'ClearButton'} | ${ClearButton}
10196
${'LogicButton'} | ${LogicButton}
102-
${'V2Button'} | ${V2Button}
10397
`('$Name supports aria-describedby', function ({Component}) {
10498
let {getByRole} = render(
10599
<>
@@ -118,7 +112,6 @@ describe('Button', function () {
118112
${'Button'} | ${Button} | ${{UNSAFE_className: 'x-men-first-class'}}
119113
${'ClearButton'} | ${ClearButton} | ${{UNSAFE_className: 'x-men-first-class'}}
120114
${'LogicButton'} | ${LogicButton} | ${{UNSAFE_className: 'x-men-first-class'}}
121-
${'V2Button'} | ${V2Button} | ${{className: 'x-men-first-class'}}
122115
`('$Name allows a custom classname on the button', function ({Component, props}) {
123116
let {getByRole} = render(<Component {...props}>Click Me</Component>);
124117

@@ -132,25 +125,21 @@ describe('Button', function () {
132125
${'Button'} | ${Button}
133126
${'ClearButton'} | ${ClearButton}
134127
${'LogicButton'} | ${LogicButton}
135-
${'V2Button'} | ${V2Button}
136128
`('$Name handles deprecated onClick', function ({Component}) {
137129
let spyWarn = jest.spyOn(console, 'warn').mockImplementation(() => {});
138130
let {getByRole} = render(<Component onClick={onPressSpy}>Click Me</Component>);
139131

140132
let button = getByRole('button');
141133
triggerPress(button);
142134
expect(onPressSpy).toHaveBeenCalledTimes(1);
143-
if (Component === Button) {
144-
expect(spyWarn).toHaveBeenCalledWith('onClick is deprecated, please use onPress');
145-
}
135+
expect(spyWarn).toHaveBeenCalledWith('onClick is deprecated, please use onPress');
146136
});
147137

148138
it.each`
149139
Name | Component | props
150140
${'ActionButton'} | ${ActionButton}| ${{onPress: onPressSpy, elementType: 'a'}}
151141
${'Button'} | ${Button} | ${{onPress: onPressSpy, elementType: 'a'}}
152142
${'LogicButton'} | ${LogicButton} | ${{onPress: onPressSpy, elementType: 'a'}}
153-
${'V2Button'} | ${V2Button} | ${{onClick: onPressSpy, element: 'a'}}
154143
`('$Name can have elementType=a', function ({Component, props}) {
155144
let {getByRole} = render(<Component {...props}>Click Me</Component>);
156145

@@ -174,7 +163,6 @@ describe('Button', function () {
174163
${'ActionButton'} | ${ActionButton}| ${{onPress: onPressSpy, elementType: 'a', href: '#only-hash-in-jsdom'}}
175164
${'Button'} | ${Button} | ${{onPress: onPressSpy, elementType: 'a', href: '#only-hash-in-jsdom'}}
176165
${'LogicButton'} | ${LogicButton} | ${{onPress: onPressSpy, elementType: 'a', href: '#only-hash-in-jsdom'}}
177-
${'V2Button'} | ${V2Button} | ${{onClick: onPressSpy, element: 'a', href: '#only-hash-in-jsdom'}}
178166
`('$Name can have elementType=a with an href', function ({Component, props}) {
179167
let {getByRole} = render(<Component {...props}>Click Me</Component>);
180168

@@ -191,7 +179,6 @@ describe('Button', function () {
191179
${'Button'} | ${Button} | ${{onPress: onPressSpy, isDisabled: true}}
192180
${'ClearButton'} | ${ClearButton} | ${{onPress: onPressSpy, isDisabled: true}}
193181
${'LogicButton'} | ${LogicButton} | ${{onPress: onPressSpy, isDisabled: true}}
194-
${'V2Button'} | ${V2Button} | ${{onClick: onPressSpy, disabled: true}}
195182
`('$Name does not respond when disabled', function ({Component, props}) {
196183
let {getByRole} = render(<Component {...props}>Click Me</Component>);
197184

packages/@react-spectrum/button/test/ClearButton.test.js

-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {act, render} from '@testing-library/react';
1414
import {ClearButton} from '../';
1515
import React from 'react';
1616
import {triggerPress} from '@react-spectrum/test-utils';
17-
import V2Button from '@react/react-spectrum/Button';
1817

1918
// NOTE: ClearButton doesn't use Button.tsx as a base and thus differs from v2 ClearButton in a couple ways
2019
// Refinement of ClearButton to be done later
@@ -29,7 +28,6 @@ describe('ClearButton', function () {
2928
it.each`
3029
Name | Component | props
3130
${'v3 ClearButton'} | ${ClearButton} | ${{onPress: onPressSpy}}
32-
${'v2 ClearButton'} | ${V2Button} | ${{variant: 'clear', onClick: onPressSpy}}
3331
`('$Name handles defaults', function ({Component, props}) {
3432
let {getByRole} = render(<Component {...props}>Click Me</Component>);
3533

@@ -41,15 +39,13 @@ describe('ClearButton', function () {
4139
it.each`
4240
Name | Component | props
4341
${'v3 ClearButton'} | ${ClearButton} | ${{}}
44-
${'v2 ClearButton'} | ${V2Button} | ${{variant: 'clear'}}
4542
`('$Name allows custom props to be passed through to the button', function ({Component, props}) {
4643
let {getByRole} = render(<Component {...props} data-foo="bar">Click Me</Component>);
4744

4845
let button = getByRole('button', {hidden: true});
4946
expect(button).toHaveAttribute('data-foo', 'bar');
5047
});
5148

52-
// Current v3 implementation that diverges from v2
5349
it.each`
5450
Name | Component
5551
${'v3 ClearButton'} | ${ClearButton}
@@ -61,7 +57,6 @@ describe('ClearButton', function () {
6157
expect(icon).toBeNull();
6258
});
6359

64-
// Only v3 allows for ref forwarding
6560
it.each`
6661
Name | Component
6762
${'v3 ClearButton'} | ${ClearButton}

packages/@react-spectrum/checkbox/test/Checkbox.test.js

-17
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {Checkbox} from '../';
1414
import React from 'react';
1515
import {render} from '@testing-library/react';
1616
import userEvent from '@testing-library/user-event';
17-
import V2Checkbox from '@react/react-spectrum/Checkbox';
1817

1918

2019
describe('Checkbox', function () {
@@ -28,8 +27,6 @@ describe('Checkbox', function () {
2827
Name | Component | props
2928
${'Checkbox'} | ${Checkbox} | ${{onChange: onChangeSpy}}
3029
${'Checkbox isEmphasized'} | ${Checkbox} | ${{onChange: onChangeSpy, isEmphasized: true}}
31-
${'V2Checkbox'} | ${V2Checkbox} | ${{onChange: onChangeSpy}}
32-
${'V2Checkbox quiet'} | ${V2Checkbox} | ${{onChange: onChangeSpy, quiet: true}}
3330
`('$Name default unchecked can be checked', function ({Component, props}) {
3431
let {getByLabelText} = render(<Component {...props}>Click Me</Component>);
3532

@@ -56,8 +53,6 @@ describe('Checkbox', function () {
5653
Name | Component | props
5754
${'Checkbox'} | ${Checkbox} | ${{onChange: onChangeSpy, defaultSelected: true}}
5855
${'Checkbox isEmphasized'} | ${Checkbox} | ${{onChange: onChangeSpy, defaultSelected: true, isEmphasized: true}}
59-
${'V2Checkbox'} | ${V2Checkbox} | ${{onChange: onChangeSpy, defaultChecked: true}}
60-
${'V2Checkbox quiet'} | ${V2Checkbox} | ${{onChange: onChangeSpy, defaultChecked: true, quiet: true}}
6156
`('$Name can be default checked', function ({Component, props}) {
6257
let {getByLabelText} = render(<Component {...props}>Click Me</Component>);
6358

@@ -74,8 +69,6 @@ describe('Checkbox', function () {
7469
Name | Component | props
7570
${'Checkbox'} | ${Checkbox} | ${{onChange: onChangeSpy, isSelected: true}}
7671
${'Checkbox isEmphasized'} | ${Checkbox} | ${{onChange: onChangeSpy, isSelected: true, isEmphasized: true}}
77-
${'V2Checkbox'} | ${V2Checkbox} | ${{onChange: onChangeSpy, checked: true}}
78-
${'V2Checkbox quiet'} | ${V2Checkbox} | ${{onChange: onChangeSpy, checked: true, quiet: true}}
7972
`('$Name can be controlled checked', function ({Component, props}) {
8073
let {getByLabelText} = render(<Component {...props}>Click Me</Component>);
8174

@@ -92,8 +85,6 @@ describe('Checkbox', function () {
9285
Name | Component | props
9386
${'Checkbox'} | ${Checkbox} | ${{onChange: onChangeSpy, isSelected: false}}
9487
${'Checkbox isEmphasized'} | ${Checkbox} | ${{onChange: onChangeSpy, isSelected: false, isEmphasized: true}}
95-
${'V2Checkbox'} | ${V2Checkbox} | ${{onChange: onChangeSpy, checked: false}}
96-
${'V2Checkbox quiet'} | ${V2Checkbox} | ${{onChange: onChangeSpy, checked: false, quiet: true}}
9788
`('$Name can be controlled unchecked', function ({Component, props}) {
9889
let {getByLabelText} = render(<Component {...props}>Click Me</Component>);
9990

@@ -110,8 +101,6 @@ describe('Checkbox', function () {
110101
Name | Component | props
111102
${'Checkbox'} | ${Checkbox} | ${{onChange: onChangeSpy, isDisabled: true}}
112103
${'Checkbox isEmphasized'} | ${Checkbox} | ${{onChange: onChangeSpy, isDisabled: true, isEmphasized: true}}
113-
${'V2Checkbox'} | ${V2Checkbox} | ${{onChange: onChangeSpy, disabled: true}}
114-
${'V2Checkbox quiet'} | ${V2Checkbox} | ${{onChange: onChangeSpy, disabled: true, quiet: true}}
115104
`('$Name can be disabled', function ({Component, props}) {
116105
let {getByLabelText} = render(<Component {...props}>Click Me</Component>);
117106

@@ -126,7 +115,6 @@ describe('Checkbox', function () {
126115
it.each`
127116
Name | Component | props
128117
${'Checkbox'} | ${Checkbox} | ${{onChange: onChangeSpy, validationState: 'invalid'}}
129-
${'V2Checkbox quiet'} | ${V2Checkbox} | ${{onChange: onChangeSpy, invalid: true, quiet: true}}
130118
`('$Name can be invalid', function ({Component, props}) {
131119
let {getByRole} = render(<Component {...props}>Click Me</Component>);
132120

@@ -149,8 +137,6 @@ describe('Checkbox', function () {
149137
Name | Component | props
150138
${'Checkbox'} | ${Checkbox} | ${{onChange: onChangeSpy, isIndeterminate: true}}
151139
${'Checkbox isEmphasized'} | ${Checkbox} | ${{onChange: onChangeSpy, isIndeterminate: true, isEmphasized: true}}
152-
${'V2Checkbox'} | ${V2Checkbox} | ${{onChange: onChangeSpy, indeterminate: true}}
153-
${'V2Checkbox quiet'} | ${V2Checkbox} | ${{onChange: onChangeSpy, indeterminate: true, quiet: true}}
154140
`('$Name can be indeterminate', function ({Component, props}) {
155141
let {getByLabelText} = render(<Component {...props}>Click Me</Component>);
156142

@@ -177,7 +163,6 @@ describe('Checkbox', function () {
177163
it.each`
178164
Name | Component | props
179165
${'Checkbox'} | ${Checkbox} | ${{onChange: onChangeSpy, 'aria-label': 'not visible'}}
180-
${'V2Checkbox quiet'} | ${V2Checkbox} | ${{onChange: onChangeSpy, 'aria-label': 'not visible', quiet: true}}
181166
`('$Name can have a non-visible label', function ({Component, props}) {
182167
let {getByRole} = render(<Component {...props} />);
183168

@@ -188,7 +173,6 @@ describe('Checkbox', function () {
188173
it.each`
189174
Name | Component | props
190175
${'Checkbox'} | ${Checkbox} | ${{onChange: onChangeSpy, 'aria-labelledby': 'test'}}
191-
${'V2Checkbox'} | ${V2Checkbox} | ${{onChange: onChangeSpy, 'aria-labelledby': 'test'}}
192176
`('$Name supports aria-labelledby', function ({Component, props}) {
193177
let {getByRole} = render(
194178
<>
@@ -204,7 +188,6 @@ describe('Checkbox', function () {
204188
it.each`
205189
Name | Component | props
206190
${'Checkbox'} | ${Checkbox} | ${{onChange: onChangeSpy, 'aria-describedby': 'test'}}
207-
${'V2Checkbox'} | ${V2Checkbox} | ${{onChange: onChangeSpy, 'aria-describedby': 'test'}}
208191
`('$Name supports aria-describedby', function ({Component, props}) {
209192
let {getByRole} = render(
210193
<>

packages/@react-spectrum/illustratedmessage/test/IllustratedMessage.test.js

-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {Heading} from '@react-spectrum/text';
1515
import {IllustratedMessage} from '../';
1616
import React from 'react';
1717
import {render} from '@testing-library/react';
18-
import V2IllustratedMessage from '@react/react-spectrum/IllustratedMessage';
1918

2019
let dataTestId = 'IMsvg1';
2120

@@ -47,7 +46,6 @@ describe('IllustratedMessage', function () {
4746
it.each`
4847
Name | Component | props
4948
${'IllustratedMessage'} | ${IllustratedMessage} | ${{heading: 'foo', description: 'bar', illustration: <Image />}}
50-
${'V2IllustratedMessage'} | ${V2IllustratedMessage} | ${{heading: 'foo', description: 'bar', illustration: <Image />}}
5149
`('$Name should render all parts of an IllustratedMessage', function ({Component, props}) {
5250
let {getByTestId, getByText} = renderIllustratedMessage(Component, props);
5351

@@ -59,7 +57,6 @@ describe('IllustratedMessage', function () {
5957
it.each`
6058
Name | Component | props
6159
${'IllustratedMessage'} | ${IllustratedMessage} | ${{illustration: <Image />}}
62-
${'V2IllustratedMessage'} | ${V2IllustratedMessage} | ${{illustration: <Image />}}
6360
`('$Name should render only an svg', function ({Component, props}) {
6461
let {queryAllByText, getByTestId} = renderIllustratedMessage(Component, props);
6562

@@ -71,7 +68,6 @@ describe('IllustratedMessage', function () {
7168
it.each`
7269
Name | Component | props
7370
${'IllustratedMessage'} | ${IllustratedMessage} | ${{heading: 'foo', description: 'bar'}}
74-
${'V2IllustratedMessage'} | ${V2IllustratedMessage} | ${{heading: 'foo', description: 'bar'}}
7571
`('$Name should render heading and description without an svg', function ({Component, props}) {
7672
let {queryAllByTestId, getByText} = renderIllustratedMessage(Component, props);
7773

packages/@react-spectrum/link/test/Link.test.js

-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {Provider} from '@react-spectrum/provider';
1616
import React from 'react';
1717
import {theme} from '@react-spectrum/theme-default';
1818
import {Tooltip, TooltipTrigger} from '@react-spectrum/tooltip';
19-
import V2Link from '@react/react-spectrum/Link';
2019

2120
// Triggers a "press" event on an element.
2221
// TODO: import from somewhere more common
@@ -46,7 +45,6 @@ describe('Link', function () {
4645
it.each`
4746
Name | Component | props
4847
${'Link'} | ${Link} | ${{onPress: onPressSpy}}
49-
${'V2Link'} | ${V2Link} | ${{onClick: onPressSpy}}
5048
`('$Name handles defaults', function ({Component, props}) {
5149
let {getByText} = render(<Component {...props} >Click me</Component>);
5250

@@ -60,15 +58,12 @@ describe('Link', function () {
6058
it.each`
6159
Name | Component | props
6260
${'Link'} | ${Link} | ${{UNSAFE_className: 'test-class'}}
63-
${'V2Link'} | ${V2Link} | ${{className: 'test-class'}}
6461
`('$Name supports UNSAFE_className', function ({Component, props}) {
6562
let {getByText} = render(<Component {...props} >Click me</Component>);
6663
let link = getByText('Click me');
6764
expect(link).toHaveAttribute('class', expect.stringContaining('test-class'));
6865
});
6966

70-
// New v3 functionality, omitting v2 component
71-
// V3 will clone custom child element and map the class/event handlers
7267
it('Wraps string to span', () => {
7368
let {getByRole} = render(<Link >Click me</Link>);
7469
let link = getByRole('link');

0 commit comments

Comments
 (0)