Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit b895ab0

Browse files
committed
Remove path aliases from react/test
1 parent 6f3dbb6 commit b895ab0

File tree

110 files changed

+262
-326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+262
-326
lines changed

.github/test-a-feature.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ These tests are typically imported into individual component tests.
5151
Every common test receives your component as its first argument.
5252

5353
```tsx
54-
import { isConformant } from 'test/specs/commonTests'
54+
import { isConformant } from '../../commonTests'
5555

56-
import Divider from 'src/components/Divider/Divider'
56+
import { Divider } from '@fluentui/react'
5757

5858
describe('Divider', () => {
5959
isConformant(Divider)
@@ -85,9 +85,9 @@ There should be one describe block for each prop of your component.
8585
Example for `Button` component:
8686

8787
```tsx
88-
import { isConformant } from 'test/specs/commonTests'
88+
import { isConformant } from '../../commonTests'
8989

90-
import Button from 'src/components/Button'
90+
import { Button } from '@fluentui/react'
9191

9292
describe('Button', () => {
9393
isConformant(Button)
@@ -242,7 +242,7 @@ Add your spec file into the array of files `skipSpecChecksForFiles` in `testHelp
242242

243243
## Performance Tests
244244

245-
Performance tests will measure performance, set a baseline for performance and help guard against regressions.
245+
Performance tests will measure performance, set a baseline for performance and help guard against regressions.
246246

247247
### Adding a Perf Test
248248

packages/accessibility/test/behaviors/behavior-test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ import {
8383
import { TestHelper } from './testHelper'
8484
import definitions from './testDefinitions'
8585

86+
// TODO (@ecraig12345) - remove relative docs import
8687
const behaviorMenuItems = require('../../../../docs/src/behaviorMenu')
8788

8889
const testHelper = new TestHelper()

packages/react-bindings/test/styles/resolveStylesAndClasses-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
emptyTheme,
55
ICSSInJSStyle,
66
} from '@fluentui/styles'
7-
import resolveStylesAndClasses from '../../src/styles/resolveStylesAndClasses'
7+
import resolveStylesAndClasses from '@fluentui/react-bindings/src/styles/resolveStylesAndClasses'
88

99
const styleParam: ComponentStyleFunctionParam = {
1010
disableAnimations: false,

packages/react/jest.config.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,5 @@ const commonConfig = require('@fluentui/internal-tooling/jest')
33
module.exports = {
44
...commonConfig,
55
name: 'react',
6-
moduleNameMapper: {
7-
...require('lerna-alias').jest(),
8-
'docs/(.*)$': `<rootDir>/../../docs/$1`,
9-
10-
// Legacy aliases, they should not be used in new tests
11-
'^src/(.*)$': `<rootDir>/src/$1`,
12-
'test/(.*)$': `<rootDir>/test/$1`,
13-
},
6+
moduleNameMapper: require('lerna-alias').jest(),
147
}

packages/react/test/specs/commonTests/handlesAccessibility.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { FocusZone, FOCUSZONE_WRAP_ATTRIBUTE } from '@fluentui/react-bindings'
88
import * as React from 'react'
99
import * as keyboardKey from 'keyboard-key'
1010

11-
import { mountWithProviderAndGetComponent, mountWithProvider } from 'test/utils'
12-
import { UIComponent } from 'src/utils'
11+
import { mountWithProviderAndGetComponent, mountWithProvider } from '../../utils'
12+
import { UIComponent } from '@fluentui/react'
1313
import { EVENT_TARGET_ATTRIBUTE, getEventTargetComponent } from './eventTarget'
1414

1515
export const getRenderedAttribute = (renderedComponent, propName, partSelector) => {

packages/react/test/specs/commonTests/htmlIsAccessibilityCompliant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import * as ReactDOMServer from 'react-dom/server'
33
import { axe, toHaveNoViolations } from 'jest-axe'
4-
import { EmptyThemeProvider } from 'test/utils'
4+
import { EmptyThemeProvider } from '../../utils'
55

66
type AxeMatcher<R> = jest.Matchers<R, any> & {
77
toHaveNoViolations: () => R

packages/react/test/specs/commonTests/implementsCollectionShorthandProp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
2-
import { mountWithProvider as mount } from 'test/utils'
2+
import { mountWithProvider as mount } from '../../utils'
33
import * as _ from 'lodash'
4-
import { PropsOf } from 'src/types'
4+
import { PropsOf } from '@fluentui/react'
55

66
export type CollectionShorthandTestOptions<TProps = any> = {
77
mapsValueToProp: keyof (TProps & React.HTMLProps<HTMLElement>) | false

packages/react/test/specs/commonTests/implementsShorthandProp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import { ReactWrapper } from 'enzyme'
3-
import { mountWithProvider } from 'test/utils'
4-
import { Props, PropsOf, InstanceOf } from 'src/types'
3+
import { mountWithProvider } from '../../utils'
4+
import { Props, PropsOf, InstanceOf } from '@fluentui/react'
55

66
export type ShorthandTestOptions<TProps = any> = {
77
mapsValueToProp: keyof (TProps & React.HTMLProps<HTMLElement>) | false

packages/react/test/specs/commonTests/implementsWrapperProp.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import * as React from 'react'
22
import { ReactWrapper } from 'enzyme'
3-
import { mountWithProvider as mount } from 'test/utils'
3+
import { mountWithProvider as mount } from '../../utils'
44

5-
import Box from 'src/components/Box/Box'
6-
import { Props, ShorthandValue } from 'src/types'
5+
import { Box, Props, ShorthandValue } from '@fluentui/react'
76

87
export interface ImplementsWrapperPropOptions {
98
wrapppedComponentSelector: any

packages/react/test/specs/commonTests/isConformant.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import {
1414
getDisplayName,
1515
mountWithProvider as mount,
1616
syntheticEvent,
17-
} from 'test/utils'
17+
} from '../../utils'
1818
import helpers from './commonHelpers'
1919

20-
import * as FluentUI from 'src/index'
20+
import * as FluentUI from '@fluentui/react'
2121
import { getEventTargetComponent, EVENT_TARGET_ATTRIBUTE } from './eventTarget'
2222

2323
export interface Conformant {
@@ -112,7 +112,8 @@ export default function isConformant(
112112
// This is pretty ugly because:
113113
// - jest doesn't support custom error messages
114114
// - jest will run all test
115-
const infoJSONPath = `docs/src/componentInfo/${constructorName}.info.json`
115+
// TODO (@ecraig12345) - remove relative docs import
116+
const infoJSONPath = `../../../../../docs/src/componentInfo/${constructorName}.info.json`
116117

117118
let info
118119

@@ -124,7 +125,7 @@ export default function isConformant(
124125
throw new Error(
125126
[
126127
'!! ==========================================================',
127-
`!! Missing ${infoJSONPath}.`,
128+
`!! Missing ${infoJSONPath.replace('../../../../../', '')}.`,
128129
'!! Run `yarn test` or `yarn test:watch` again to generate one.',
129130
'!! ==========================================================',
130131
].join('\n'),

packages/react/test/specs/commonTests/isExportedAtTopLevel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as _ from 'lodash'
2-
import * as FluentUI from 'src/index'
2+
import * as FluentUI from '@fluentui/react'
33

44
// ----------------------------------------
55
// Is exported or private
@@ -12,7 +12,7 @@ export default (constructorName: string, displayName: string) => {
1212
test('is exported at the top level', () => {
1313
const message = [
1414
`'${displayName}' must be exported at top level.`,
15-
"Export it in 'src/index.js'.",
15+
"Export it in 'src/index.ts'.",
1616
].join(' ')
1717

1818
expect({ isTopLevelAPIProp, message }).toEqual({

packages/react/test/specs/commonTests/stylesFunction-test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Extendable, ICSSInJSStyle } from '@fluentui/styles'
22
import * as React from 'react'
33
import * as PropTypes from 'prop-types'
44
import * as _ from 'lodash'
5-
import { UIComponent } from 'src/utils'
6-
import { mountWithProviderAndGetComponent } from 'test/utils'
5+
import { UIComponent } from '@fluentui/react'
6+
import { mountWithProviderAndGetComponent } from '../../utils'
77

88
type AttrValue = 'props' | 'state'
99

packages/react/test/specs/components/Accordion/Accordion-test.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react'
22
import * as keyboardKey from 'keyboard-key'
33

4-
import Accordion from 'src/components/Accordion/Accordion'
5-
import { isConformant, handlesAccessibility } from 'test/specs/commonTests'
6-
import { mountWithProvider, mountWithProviderAndGetComponent } from 'test/utils'
7-
import AccordionTitle from 'src/components/Accordion/AccordionTitle'
4+
import { Accordion, AccordionTitle } from '@fluentui/react'
5+
import { isConformant, handlesAccessibility } from '../../commonTests'
6+
import { mountWithProvider, mountWithProviderAndGetComponent } from '../../../utils'
87
import { ReactWrapper, CommonWrapper } from 'enzyme'
98

109
const panels = [

packages/react/test/specs/components/Accordion/AccordionContent-test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from 'react'
22

3-
import AccordionContent from 'src/components/Accordion/AccordionContent'
4-
import { isConformant, handlesAccessibility, getRenderedAttribute } from 'test/specs/commonTests'
5-
import { mountWithProviderAndGetComponent } from 'test/utils'
3+
import { AccordionContent } from '@fluentui/react'
4+
import { isConformant, handlesAccessibility, getRenderedAttribute } from '../../commonTests'
5+
import { mountWithProviderAndGetComponent } from '../../../utils'
66

77
describe('AccordionContent', () => {
88
isConformant(AccordionContent)

packages/react/test/specs/components/Accordion/AccordionTitle-test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import AccordionTitle from 'src/components/Accordion/AccordionTitle'
2-
import { isConformant, handlesAccessibility } from 'test/specs/commonTests'
1+
import { AccordionTitle } from '@fluentui/react'
2+
import { isConformant, handlesAccessibility } from '../../commonTests'
33

44
describe('AccordionTitle', () => {
55
isConformant(AccordionTitle, {

packages/react/test/specs/components/Alert/Alert-test.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import {
55
implementsShorthandProp,
66
handlesAccessibility,
77
htmlIsAccessibilityCompliant,
8-
} from 'test/specs/commonTests'
8+
} from '../../commonTests'
99

10-
import Alert from 'src/components/Alert/Alert'
11-
import Box from 'src/components/Box/Box'
12-
import Button from 'src/components/Button/Button'
10+
import { Alert, Box, Button } from '@fluentui/react'
1311

1412
const alertImplementsShorthandProp = implementsShorthandProp(Alert)
1513

packages/react/test/specs/components/Animation/Animation-test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { isConformant } from 'test/specs/commonTests'
1+
import { isConformant } from '../../commonTests'
22

3-
import Animation from 'src/components/Animation/Animation'
3+
import { Animation } from '@fluentui/react'
44

55
describe('Animation', () => {
66
isConformant(Animation, { hasAccessibilityProp: false })

packages/react/test/specs/components/Attachment/Attachment-test.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import * as React from 'react'
2-
import { isConformant, implementsShorthandProp, handlesAccessibility } from 'test/specs/commonTests'
3-
import { mountWithProvider, findIntrinsicElement } from 'test/utils'
2+
import { isConformant, implementsShorthandProp, handlesAccessibility } from '../../commonTests'
3+
import { mountWithProvider, findIntrinsicElement } from '../../../utils'
44
import * as keyboardKey from 'keyboard-key'
55

6-
import Attachment from 'src/components/Attachment/Attachment'
7-
import Text from 'src/components/Text/Text'
8-
import Icon from 'src/components/Icon/Icon'
9-
import Button from 'src/components/Button/Button'
6+
import { Attachment, Text, Icon, Button } from '@fluentui/react'
107
import { ReactWrapper } from 'enzyme'
118

129
const attachmentImplementsShorthandProp = implementsShorthandProp(Attachment)

packages/react/test/specs/components/Avatar/Avatar-test.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { implementsShorthandProp, isConformant } from 'test/specs/commonTests'
1+
import { implementsShorthandProp, isConformant } from '../../commonTests'
22

3-
import Avatar from 'src/components/Avatar/Avatar'
4-
import Label from 'src/components/Label/Label'
5-
import Image from 'src/components/Image/Image'
3+
import { Avatar, Label, Image } from '@fluentui/react'
64

75
const avatarImplementsShorthandProp = implementsShorthandProp(Avatar)
86
const { getInitials } = (Avatar as any).defaultProps

packages/react/test/specs/components/Button/Button-test.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import {
66
htmlIsAccessibilityCompliant,
77
implementsShorthandProp,
88
getRenderedAttribute,
9-
} from 'test/specs/commonTests'
10-
import { mountWithProvider, mountWithProviderAndGetComponent } from 'test/utils'
9+
} from '../../commonTests'
10+
import { mountWithProvider, mountWithProviderAndGetComponent } from '../../../utils'
1111
import { toggleButtonBehavior } from '@fluentui/accessibility'
1212

13-
import Button from 'src/components/Button/Button'
14-
import Icon from 'src/components/Icon/Icon'
13+
import { Button, Icon } from '@fluentui/react'
1514

1615
const buttonImplementsShorthandProp = implementsShorthandProp(Button)
1716

packages/react/test/specs/components/Button/ButtonGroup-test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { isConformant } from 'test/specs/commonTests'
2-
import ButtonGroup from 'src/components/Button/ButtonGroup'
1+
import { isConformant } from '../../commonTests'
2+
import { ButtonGroup, Button } from '@fluentui/react'
33
import implementsCollectionShorthandProp from '../../commonTests/implementsCollectionShorthandProp'
4-
import Button from 'src/components/Button/Button'
54

65
const buttonGroupImplementsCollectionShorthandProp = implementsCollectionShorthandProp(ButtonGroup)
76

packages/react/test/specs/components/Carousel/Carousel-test.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import * as React from 'react'
22

3-
import { isConformant } from 'test/specs/commonTests'
4-
import Carousel, { CarouselProps } from 'src/components/Carousel/Carousel'
5-
import CarouselItem from 'src/components/Carousel/CarouselItem'
6-
import CarouselNavigation from 'src/components/Carousel/CarouselNavigation'
7-
import CarouselNavigationItem from 'src/components/Carousel/CarouselNavigationItem'
8-
import Text from 'src/components/Text/Text'
3+
import { isConformant } from '../../commonTests'
4+
import {
5+
Carousel,
6+
CarouselProps,
7+
CarouselItem,
8+
CarouselNavigation,
9+
CarouselNavigationItem,
10+
Text,
11+
} from '@fluentui/react'
912
import { ReactWrapper, CommonWrapper } from 'enzyme'
10-
import { findIntrinsicElement, mountWithProvider } from 'test/utils'
13+
import { findIntrinsicElement, mountWithProvider } from '../../../utils'
1114

1215
const items = [
1316
{

packages/react/test/specs/components/Carousel/CarouselItem-test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as React from 'react'
22

3-
import { isConformant } from 'test/specs/commonTests'
4-
import CarouselItem, { CarouselItemProps } from 'src/components/Carousel/CarouselItem'
3+
import { isConformant } from '../../commonTests'
4+
import { CarouselItem, CarouselItemProps } from '@fluentui/react'
55
import { ReactWrapper, CommonWrapper } from 'enzyme'
6-
import { findIntrinsicElement, mountWithProvider } from 'test/utils'
6+
import { findIntrinsicElement, mountWithProvider } from '../../../utils'
77

88
function renderCarouselItem(props?: CarouselItemProps): ReactWrapper {
99
return mountWithProvider(<CarouselItem {...props} />)

packages/react/test/specs/components/Carousel/CarouselNavigation-test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { isConformant } from 'test/specs/commonTests'
2-
import CarouselNavigation from 'src/components/Carousel/CarouselNavigation'
1+
import { isConformant } from '../../commonTests'
2+
import { CarouselNavigation } from '@fluentui/react'
33

44
describe('CarouselNavigation', () => {
55
isConformant(CarouselNavigation)

packages/react/test/specs/components/Carousel/CarouselNavigationItem-test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { isConformant } from 'test/specs/commonTests'
2-
import CarouselNavigationItem from 'src/components/Carousel/CarouselNavigationItem'
1+
import { isConformant } from '../../commonTests'
2+
import { CarouselNavigationItem } from '@fluentui/react'
33

44
describe('CarouselNavigationItem', () => {
55
isConformant(CarouselNavigationItem)

packages/react/test/specs/components/Chat/Chat-test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { chatBehavior, AccessibilityDefinition } from '@fluentui/accessibility'
2-
import { handlesAccessibility, isConformant } from 'test/specs/commonTests'
2+
import { handlesAccessibility, isConformant } from '../../commonTests'
33

4-
import Chat from 'src/components/Chat/Chat'
4+
import { Chat, ChatItem } from '@fluentui/react'
55
import implementsCollectionShorthandProp from '../../commonTests/implementsCollectionShorthandProp'
6-
import ChatItem from 'src/components/Chat/ChatItem'
76

87
const chatImplementsCollectionShorthandProp = implementsCollectionShorthandProp(Chat)
98

packages/react/test/specs/components/Chat/ChatItem-test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { isConformant, implementsShorthandProp } from 'test/specs/commonTests'
2-
import ChatItem from 'src/components/Chat/ChatItem'
3-
import Box from 'src/components/Box/Box'
1+
import { isConformant, implementsShorthandProp } from '../../commonTests'
2+
import { ChatItem, Box } from '@fluentui/react'
43

54
const chatItemImplementsShorthandProp = implementsShorthandProp(ChatItem)
65

packages/react/test/specs/components/Chat/ChatMessage-test.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { chatMessageBehavior, AccessibilityDefinition } from '@fluentui/accessibility'
22
import * as React from 'react'
33

4-
import { handlesAccessibility, implementsShorthandProp, isConformant } from 'test/specs/commonTests'
5-
import { mountWithProvider } from 'test/utils'
4+
import { handlesAccessibility, implementsShorthandProp, isConformant } from '../../commonTests'
5+
import { mountWithProvider } from '../../../utils'
66

7-
import ChatMessage from 'src/components/Chat/ChatMessage'
8-
import Text from 'src/components/Text/Text'
9-
import Box from 'src/components/Box/Box'
7+
import { ChatMessage, Text, Box } from '@fluentui/react'
108

119
const chatMessageImplementsShorthandProp = implementsShorthandProp(ChatMessage)
1210

packages/react/test/specs/components/Checkbox/Checkbox-test.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import * as React from 'react'
2-
import Checkbox from 'src/components/Checkbox/Checkbox'
3-
import {
4-
isConformant,
5-
handlesAccessibility,
6-
htmlIsAccessibilityCompliant,
7-
} from 'test/specs/commonTests'
2+
import { Checkbox } from '@fluentui/react'
3+
import { isConformant, handlesAccessibility, htmlIsAccessibilityCompliant } from '../../commonTests'
84

95
describe('Checkbox', () => {
106
isConformant(Checkbox)

packages/react/test/specs/components/Debug/utils-test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { find, isOverridden, filter, getValues, removeNulls } from 'src/components/Debug/utils'
1+
import {
2+
find,
3+
isOverridden,
4+
filter,
5+
getValues,
6+
removeNulls,
7+
} from '@fluentui/react/src/components/Debug/utils'
28

39
describe('debugUtils', () => {
410
describe('find', () => {

0 commit comments

Comments
 (0)