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'),

0 commit comments

Comments
 (0)