@atlaskit/media-test-helpers 39.0.16 → 40.0.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/CHANGELOG.md +12 -0
- package/dist/cjs/index.js +3 -15
- package/dist/cjs/renderWithIntl.js +7 -2
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/renderWithIntl.js +7 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/renderWithIntl.js +6 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/renderWithIntl.d.ts +5 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/renderWithIntl.d.ts +5 -1
- package/package.json +1 -2
- package/report.api.md +2 -41
- package/dist/cjs/mountWithIntlContext.js +0 -70
- package/dist/es2019/mountWithIntlContext.js +0 -58
- package/dist/esm/mountWithIntlContext.js +0 -63
- package/dist/types/mountWithIntlContext.d.ts +0 -12
- package/dist/types-ts4.5/mountWithIntlContext.d.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/media-test-helpers
|
|
2
2
|
|
|
3
|
+
## 40.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`5fb7e85e19555`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5fb7e85e19555) -
|
|
8
|
+
**BREAKING CHANGE:** Removed `mountWithIntlContext`, `mountWithIntlWrapper`, and
|
|
9
|
+
`shallowWithIntlContext`. Use `renderWithIntl` instead for tests.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 39.0.16
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -563,18 +563,6 @@ Object.defineProperty(exports, "mockLoadImageError", {
|
|
|
563
563
|
return _mockLoadImage.mockLoadImageError;
|
|
564
564
|
}
|
|
565
565
|
});
|
|
566
|
-
Object.defineProperty(exports, "mountWithIntlContext", {
|
|
567
|
-
enumerable: true,
|
|
568
|
-
get: function get() {
|
|
569
|
-
return _mountWithIntlContext.mountWithIntlContext;
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
Object.defineProperty(exports, "mountWithIntlWrapper", {
|
|
573
|
-
enumerable: true,
|
|
574
|
-
get: function get() {
|
|
575
|
-
return _mountWithIntlContext.mountWithIntlWrapper;
|
|
576
|
-
}
|
|
577
|
-
});
|
|
578
566
|
Object.defineProperty(exports, "nextTick", {
|
|
579
567
|
enumerable: true,
|
|
580
568
|
get: function get() {
|
|
@@ -605,10 +593,10 @@ Object.defineProperty(exports, "remoteImage", {
|
|
|
605
593
|
return _images.remoteImage;
|
|
606
594
|
}
|
|
607
595
|
});
|
|
608
|
-
Object.defineProperty(exports, "
|
|
596
|
+
Object.defineProperty(exports, "renderWithIntl", {
|
|
609
597
|
enumerable: true,
|
|
610
598
|
get: function get() {
|
|
611
|
-
return
|
|
599
|
+
return _renderWithIntl.renderWithIntl;
|
|
612
600
|
}
|
|
613
601
|
});
|
|
614
602
|
Object.defineProperty(exports, "simulateAlwaysLoading", {
|
|
@@ -897,7 +885,7 @@ var _nextTick = require("./nextTick");
|
|
|
897
885
|
var _timeoutPromise = require("./timeoutPromise");
|
|
898
886
|
var _jestHelpers = require("./jestHelpers");
|
|
899
887
|
var _I18nWrapper = require("./I18nWrapper");
|
|
900
|
-
var
|
|
888
|
+
var _renderWithIntl = require("./renderWithIntl");
|
|
901
889
|
var _fakeI18n = require("./fakeI18n");
|
|
902
890
|
var _mockCanvas = require("./mockCanvas");
|
|
903
891
|
var _keyboardEventWithKeyCode = _interopRequireDefault(require("./keyboardEventWithKeyCode"));
|
|
@@ -7,9 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.renderWithIntl = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntlNext = require("react-intl-next");
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Lazy require to avoid loading @testing-library/react during SSR tests.
|
|
12
|
+
* jest.resetModules() clears the cache, so RTL would register its hooks inside tests.
|
|
13
|
+
*/
|
|
11
14
|
var renderWithIntl = exports.renderWithIntl = function renderWithIntl(component) {
|
|
12
|
-
|
|
15
|
+
var _require = require('@testing-library/react'),
|
|
16
|
+
render = _require.render;
|
|
17
|
+
return render( /*#__PURE__*/_react.default.createElement(_reactIntlNext.IntlProvider, {
|
|
13
18
|
locale: "en"
|
|
14
19
|
}, component));
|
|
15
20
|
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export { nextTick, sleep } from './nextTick';
|
|
|
21
21
|
export { timeoutPromise } from './timeoutPromise';
|
|
22
22
|
export { asMock, asMockFunction, asMockReturnValue, asMockFunctionReturnValue, asMockFunctionResolvedValue, expectConstructorToHaveBeenCalledWith, expectFunctionToHaveBeenCalledWith, expectToEqual } from './jestHelpers';
|
|
23
23
|
export { I18NWrapper } from './I18nWrapper';
|
|
24
|
-
export {
|
|
24
|
+
export { renderWithIntl } from './renderWithIntl';
|
|
25
25
|
export { fakeIntl } from './fakeI18n';
|
|
26
26
|
export { mockCanvas } from './mockCanvas';
|
|
27
27
|
export { default as KeyboardEventWithKeyCode } from './keyboardEventWithKeyCode';
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IntlProvider } from 'react-intl-next';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Lazy require to avoid loading @testing-library/react during SSR tests.
|
|
5
|
+
* jest.resetModules() clears the cache, so RTL would register its hooks inside tests.
|
|
6
|
+
*/
|
|
4
7
|
export const renderWithIntl = component => {
|
|
8
|
+
const {
|
|
9
|
+
render
|
|
10
|
+
} = require('@testing-library/react');
|
|
5
11
|
return render( /*#__PURE__*/React.createElement(IntlProvider, {
|
|
6
12
|
locale: "en"
|
|
7
13
|
}, component));
|
package/dist/esm/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export { nextTick, sleep } from './nextTick';
|
|
|
21
21
|
export { timeoutPromise } from './timeoutPromise';
|
|
22
22
|
export { asMock, asMockFunction, asMockReturnValue, asMockFunctionReturnValue, asMockFunctionResolvedValue, expectConstructorToHaveBeenCalledWith, expectFunctionToHaveBeenCalledWith, expectToEqual } from './jestHelpers';
|
|
23
23
|
export { I18NWrapper } from './I18nWrapper';
|
|
24
|
-
export {
|
|
24
|
+
export { renderWithIntl } from './renderWithIntl';
|
|
25
25
|
export { fakeIntl } from './fakeI18n';
|
|
26
26
|
export { mockCanvas } from './mockCanvas';
|
|
27
27
|
export { default as KeyboardEventWithKeyCode } from './keyboardEventWithKeyCode';
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IntlProvider } from 'react-intl-next';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Lazy require to avoid loading @testing-library/react during SSR tests.
|
|
5
|
+
* jest.resetModules() clears the cache, so RTL would register its hooks inside tests.
|
|
6
|
+
*/
|
|
4
7
|
export var renderWithIntl = function renderWithIntl(component) {
|
|
8
|
+
var _require = require('@testing-library/react'),
|
|
9
|
+
render = _require.render;
|
|
5
10
|
return render( /*#__PURE__*/React.createElement(IntlProvider, {
|
|
6
11
|
locale: "en"
|
|
7
12
|
}, component));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { asMock, asMockFunction, asMockReturnValue, asMockFunctionReturnValue, a
|
|
|
27
27
|
export type { ExpectConstructorToHaveBeenCalledWith, ExpectFunctionToHaveBeenCalledWith, JestSpy, JestFunction, } from './jestHelpers';
|
|
28
28
|
export { I18NWrapper } from './I18nWrapper';
|
|
29
29
|
export type { I18NWrapperProps, I18NWrapperState } from './I18nWrapper';
|
|
30
|
-
export {
|
|
30
|
+
export { renderWithIntl } from './renderWithIntl';
|
|
31
31
|
export { fakeIntl } from './fakeI18n';
|
|
32
32
|
export { mockCanvas } from './mockCanvas';
|
|
33
33
|
export { default as KeyboardEventWithKeyCode } from './keyboardEventWithKeyCode';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { RenderResult } from '@testing-library/react';
|
|
3
|
+
/**
|
|
4
|
+
* Lazy require to avoid loading @testing-library/react during SSR tests.
|
|
5
|
+
* jest.resetModules() clears the cache, so RTL would register its hooks inside tests.
|
|
6
|
+
*/
|
|
3
7
|
export declare const renderWithIntl: (component: React.ReactNode) => RenderResult;
|
|
@@ -27,7 +27,7 @@ export { asMock, asMockFunction, asMockReturnValue, asMockFunctionReturnValue, a
|
|
|
27
27
|
export type { ExpectConstructorToHaveBeenCalledWith, ExpectFunctionToHaveBeenCalledWith, JestSpy, JestFunction, } from './jestHelpers';
|
|
28
28
|
export { I18NWrapper } from './I18nWrapper';
|
|
29
29
|
export type { I18NWrapperProps, I18NWrapperState } from './I18nWrapper';
|
|
30
|
-
export {
|
|
30
|
+
export { renderWithIntl } from './renderWithIntl';
|
|
31
31
|
export { fakeIntl } from './fakeI18n';
|
|
32
32
|
export { mockCanvas } from './mockCanvas';
|
|
33
33
|
export { default as KeyboardEventWithKeyCode } from './keyboardEventWithKeyCode';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { RenderResult } from '@testing-library/react';
|
|
3
|
+
/**
|
|
4
|
+
* Lazy require to avoid loading @testing-library/react during SSR tests.
|
|
5
|
+
* jest.resetModules() clears the cache, so RTL would register its hooks inside tests.
|
|
6
|
+
*/
|
|
3
7
|
export declare const renderWithIntl: (component: React.ReactNode) => RenderResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-test-helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "40.0.0",
|
|
4
4
|
"description": "Collection of test helpers used in media component stories and specs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"@emotion/react": "^11.7.1",
|
|
47
47
|
"@emotion/styled": "^11.0.0",
|
|
48
48
|
"@testing-library/react": "^16.3.0",
|
|
49
|
-
"enzyme": "^3.10.0",
|
|
50
49
|
"exenv": "^1.2.2",
|
|
51
50
|
"kakapo": "^4.0.6",
|
|
52
51
|
"mock-socket": "^9.3.1",
|
package/report.api.md
CHANGED
|
@@ -40,11 +40,10 @@ import { MediaType } from '@atlaskit/media-client';
|
|
|
40
40
|
import { PollingError } from '@atlaskit/media-client';
|
|
41
41
|
import { default as React_2 } from 'react';
|
|
42
42
|
import { ReactNode } from 'react';
|
|
43
|
-
import { ReactWrapper } from 'enzyme';
|
|
44
43
|
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
45
44
|
import { RequestError } from '@atlaskit/media-client';
|
|
46
45
|
import { RequestErrorMetadata } from '@atlaskit/media-client';
|
|
47
|
-
import {
|
|
46
|
+
import { type RenderResult } from '@testing-library/react';
|
|
48
47
|
import { StyledComponent } from '@emotion/styled-base';
|
|
49
48
|
import { TableHTMLAttributes } from 'react';
|
|
50
49
|
import { WrappedComponentProps } from 'react-intl-next';
|
|
@@ -759,29 +758,6 @@ interface MockStub<T, R> extends MockFunction<T> {
|
|
|
759
758
|
mockReturnValue: (value: T) => R;
|
|
760
759
|
}
|
|
761
760
|
|
|
762
|
-
// @public (undocumented)
|
|
763
|
-
export const mountWithIntlContext: <
|
|
764
|
-
P,
|
|
765
|
-
S,
|
|
766
|
-
C extends React_2.Component<P, S, any> = React_2.Component<P, S, any>,
|
|
767
|
-
>(
|
|
768
|
-
node: React_2.ReactElement<
|
|
769
|
-
P & WrappedComponentProps<'intl'>,
|
|
770
|
-
React_2.JSXElementConstructor<any> | string
|
|
771
|
-
>,
|
|
772
|
-
{
|
|
773
|
-
context,
|
|
774
|
-
childContextTypes,
|
|
775
|
-
...additionalOptions
|
|
776
|
-
}?: {
|
|
777
|
-
context?: undefined | {};
|
|
778
|
-
childContextTypes?: undefined | {};
|
|
779
|
-
},
|
|
780
|
-
) => ReactWrapper<P & WrappedComponentProps<'intl'>, S, C>;
|
|
781
|
-
|
|
782
|
-
// @public (undocumented)
|
|
783
|
-
export const mountWithIntlWrapper: (node: React_2.ReactElement) => ReactWrapper;
|
|
784
|
-
|
|
785
761
|
// @public (undocumented)
|
|
786
762
|
export interface MouseEventProps {
|
|
787
763
|
// (undocumented)
|
|
@@ -813,22 +789,7 @@ export const remoteImage =
|
|
|
813
789
|
'https://mediaviewer-examples.s3-ap-southeast-2.amazonaws.com/image/image.jpg';
|
|
814
790
|
|
|
815
791
|
// @public (undocumented)
|
|
816
|
-
export const
|
|
817
|
-
P,
|
|
818
|
-
S,
|
|
819
|
-
C extends React_2.Component<P, S, any> = React_2.Component<P, S, any>,
|
|
820
|
-
>(
|
|
821
|
-
node: React_2.ReactElement<
|
|
822
|
-
P & WrappedComponentProps<'intl'>,
|
|
823
|
-
React_2.JSXElementConstructor<any> | string
|
|
824
|
-
>,
|
|
825
|
-
{
|
|
826
|
-
context,
|
|
827
|
-
...additionalOptions
|
|
828
|
-
}?: {
|
|
829
|
-
context?: undefined | {};
|
|
830
|
-
},
|
|
831
|
-
) => ShallowWrapper<P & WrappedComponentProps<'intl'>, S, C>;
|
|
792
|
+
export const renderWithIntl: (component: React_2.ReactNode) => RenderResult;
|
|
832
793
|
|
|
833
794
|
// @public (undocumented)
|
|
834
795
|
export const simulateAlwaysLoading: SimulationFactory;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.shallowWithIntlContext = exports.mountWithIntlWrapper = exports.mountWithIntlContext = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
var _reactIntlNext = require("react-intl-next");
|
|
12
|
-
var _enzyme = require("enzyme");
|
|
13
|
-
var _excluded = ["context", "childContextTypes"],
|
|
14
|
-
_excluded2 = ["context"];
|
|
15
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
-
var mockIntl = (0, _reactIntlNext.createIntl)({
|
|
18
|
-
locale: 'en'
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* When using React-Intl `injectIntl` on components, props.intl is required.
|
|
23
|
-
*/
|
|
24
|
-
function nodeWithIntlProp(node) {
|
|
25
|
-
var intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
26
|
-
return /*#__PURE__*/_react.default.createElement(_reactIntlNext.RawIntlProvider, {
|
|
27
|
-
value: intl
|
|
28
|
-
}, /*#__PURE__*/_react.default.cloneElement(node, {
|
|
29
|
-
intl: intl
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/* TODO: We are explicitly using the third arg of ReactWrapper to work around the following TS issue which prevents a d.ts from being generated
|
|
34
|
-
* and therefore fails the build:
|
|
35
|
-
* error TS2742: The inferred type of 'mountWithIntlContext' cannot be named without a reference to 'react-transition-group/node_modules/@types/react'. This is likely not portable. A type annotation is necessary.
|
|
36
|
-
* TS is resolving enzyme's usage of react to react-transition-group???
|
|
37
|
-
*/
|
|
38
|
-
var mountWithIntlContext = exports.mountWithIntlContext = function mountWithIntlContext(node) {
|
|
39
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
40
|
-
var _ref$context = _ref.context,
|
|
41
|
-
context = _ref$context === void 0 ? {} : _ref$context,
|
|
42
|
-
_ref$childContextType = _ref.childContextTypes,
|
|
43
|
-
childContextTypes = _ref$childContextType === void 0 ? {} : _ref$childContextType,
|
|
44
|
-
additionalOptions = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
45
|
-
var intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
46
|
-
return (0, _enzyme.mount)(nodeWithIntlProp(node), _objectSpread({
|
|
47
|
-
context: _objectSpread({
|
|
48
|
-
intl: intl
|
|
49
|
-
}, context)
|
|
50
|
-
}, additionalOptions));
|
|
51
|
-
};
|
|
52
|
-
var shallowWithIntlContext = exports.shallowWithIntlContext = function shallowWithIntlContext(node) {
|
|
53
|
-
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
54
|
-
var _ref2$context = _ref2.context,
|
|
55
|
-
context = _ref2$context === void 0 ? {} : _ref2$context,
|
|
56
|
-
additionalOptions = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
|
|
57
|
-
var intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
58
|
-
return (0, _enzyme.shallow)(nodeWithIntlProp(node), _objectSpread({
|
|
59
|
-
context: _objectSpread({
|
|
60
|
-
intl: intl
|
|
61
|
-
}, context)
|
|
62
|
-
}, additionalOptions));
|
|
63
|
-
};
|
|
64
|
-
var mountWithIntlWrapper = exports.mountWithIntlWrapper = function mountWithIntlWrapper(node) {
|
|
65
|
-
return (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(function (props) {
|
|
66
|
-
return /*#__PURE__*/_react.default.createElement(_reactIntlNext.IntlProvider, {
|
|
67
|
-
locale: "en"
|
|
68
|
-
}, /*#__PURE__*/_react.default.cloneElement(node, _objectSpread({}, props)));
|
|
69
|
-
}));
|
|
70
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { RawIntlProvider, createIntl, IntlProvider } from 'react-intl-next';
|
|
3
|
-
import { mount, shallow } from 'enzyme';
|
|
4
|
-
const mockIntl = createIntl({
|
|
5
|
-
locale: 'en'
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* When using React-Intl `injectIntl` on components, props.intl is required.
|
|
10
|
-
*/
|
|
11
|
-
function nodeWithIntlProp(node) {
|
|
12
|
-
const intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
13
|
-
return /*#__PURE__*/React.createElement(RawIntlProvider, {
|
|
14
|
-
value: intl
|
|
15
|
-
}, /*#__PURE__*/React.cloneElement(node, {
|
|
16
|
-
intl
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/* TODO: We are explicitly using the third arg of ReactWrapper to work around the following TS issue which prevents a d.ts from being generated
|
|
21
|
-
* and therefore fails the build:
|
|
22
|
-
* error TS2742: The inferred type of 'mountWithIntlContext' cannot be named without a reference to 'react-transition-group/node_modules/@types/react'. This is likely not portable. A type annotation is necessary.
|
|
23
|
-
* TS is resolving enzyme's usage of react to react-transition-group???
|
|
24
|
-
*/
|
|
25
|
-
export const mountWithIntlContext = (node, {
|
|
26
|
-
context = {},
|
|
27
|
-
childContextTypes = {},
|
|
28
|
-
...additionalOptions
|
|
29
|
-
} = {}) => {
|
|
30
|
-
const intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
31
|
-
return mount(nodeWithIntlProp(node), {
|
|
32
|
-
context: {
|
|
33
|
-
intl,
|
|
34
|
-
...context
|
|
35
|
-
},
|
|
36
|
-
...additionalOptions
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
export const shallowWithIntlContext = (node, {
|
|
40
|
-
context = {},
|
|
41
|
-
...additionalOptions
|
|
42
|
-
} = {}) => {
|
|
43
|
-
const intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
44
|
-
return shallow(nodeWithIntlProp(node), {
|
|
45
|
-
context: {
|
|
46
|
-
intl,
|
|
47
|
-
...context
|
|
48
|
-
},
|
|
49
|
-
...additionalOptions
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
export const mountWithIntlWrapper = node => {
|
|
53
|
-
return mount( /*#__PURE__*/React.createElement(props => /*#__PURE__*/React.createElement(IntlProvider, {
|
|
54
|
-
locale: "en"
|
|
55
|
-
}, /*#__PURE__*/React.cloneElement(node, {
|
|
56
|
-
...props
|
|
57
|
-
}))));
|
|
58
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["context", "childContextTypes"],
|
|
4
|
-
_excluded2 = ["context"];
|
|
5
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { RawIntlProvider, createIntl, IntlProvider } from 'react-intl-next';
|
|
9
|
-
import { mount, shallow } from 'enzyme';
|
|
10
|
-
var mockIntl = createIntl({
|
|
11
|
-
locale: 'en'
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* When using React-Intl `injectIntl` on components, props.intl is required.
|
|
16
|
-
*/
|
|
17
|
-
function nodeWithIntlProp(node) {
|
|
18
|
-
var intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
19
|
-
return /*#__PURE__*/React.createElement(RawIntlProvider, {
|
|
20
|
-
value: intl
|
|
21
|
-
}, /*#__PURE__*/React.cloneElement(node, {
|
|
22
|
-
intl: intl
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* TODO: We are explicitly using the third arg of ReactWrapper to work around the following TS issue which prevents a d.ts from being generated
|
|
27
|
-
* and therefore fails the build:
|
|
28
|
-
* error TS2742: The inferred type of 'mountWithIntlContext' cannot be named without a reference to 'react-transition-group/node_modules/@types/react'. This is likely not portable. A type annotation is necessary.
|
|
29
|
-
* TS is resolving enzyme's usage of react to react-transition-group???
|
|
30
|
-
*/
|
|
31
|
-
export var mountWithIntlContext = function mountWithIntlContext(node) {
|
|
32
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33
|
-
var _ref$context = _ref.context,
|
|
34
|
-
context = _ref$context === void 0 ? {} : _ref$context,
|
|
35
|
-
_ref$childContextType = _ref.childContextTypes,
|
|
36
|
-
childContextTypes = _ref$childContextType === void 0 ? {} : _ref$childContextType,
|
|
37
|
-
additionalOptions = _objectWithoutProperties(_ref, _excluded);
|
|
38
|
-
var intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
39
|
-
return mount(nodeWithIntlProp(node), _objectSpread({
|
|
40
|
-
context: _objectSpread({
|
|
41
|
-
intl: intl
|
|
42
|
-
}, context)
|
|
43
|
-
}, additionalOptions));
|
|
44
|
-
};
|
|
45
|
-
export var shallowWithIntlContext = function shallowWithIntlContext(node) {
|
|
46
|
-
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
47
|
-
var _ref2$context = _ref2.context,
|
|
48
|
-
context = _ref2$context === void 0 ? {} : _ref2$context,
|
|
49
|
-
additionalOptions = _objectWithoutProperties(_ref2, _excluded2);
|
|
50
|
-
var intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
51
|
-
return shallow(nodeWithIntlProp(node), _objectSpread({
|
|
52
|
-
context: _objectSpread({
|
|
53
|
-
intl: intl
|
|
54
|
-
}, context)
|
|
55
|
-
}, additionalOptions));
|
|
56
|
-
};
|
|
57
|
-
export var mountWithIntlWrapper = function mountWithIntlWrapper(node) {
|
|
58
|
-
return mount( /*#__PURE__*/React.createElement(function (props) {
|
|
59
|
-
return /*#__PURE__*/React.createElement(IntlProvider, {
|
|
60
|
-
locale: "en"
|
|
61
|
-
}, /*#__PURE__*/React.cloneElement(node, _objectSpread({}, props)));
|
|
62
|
-
}));
|
|
63
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import { type ReactWrapper, type ShallowWrapper } from 'enzyme';
|
|
4
|
-
import { type Component, type ReactElement } from 'react';
|
|
5
|
-
export declare const mountWithIntlContext: <P, S, C extends Component<P, S> = Component<P, S>>(node: ReactElement<P & WrappedComponentProps>, { context, childContextTypes, ...additionalOptions }?: {
|
|
6
|
-
context?: {} | undefined;
|
|
7
|
-
childContextTypes?: {} | undefined;
|
|
8
|
-
}) => ReactWrapper<P & WrappedComponentProps, S, C>;
|
|
9
|
-
export declare const shallowWithIntlContext: <P, S, C extends Component<P, S> = Component<P, S>>(node: ReactElement<P & WrappedComponentProps>, { context, ...additionalOptions }?: {
|
|
10
|
-
context?: {} | undefined;
|
|
11
|
-
}) => ShallowWrapper<P & WrappedComponentProps, S, C>;
|
|
12
|
-
export declare const mountWithIntlWrapper: (node: React.ReactElement) => ReactWrapper;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import { type ReactWrapper, type ShallowWrapper } from 'enzyme';
|
|
4
|
-
import { type Component, type ReactElement } from 'react';
|
|
5
|
-
export declare const mountWithIntlContext: <P, S, C extends Component<P, S> = Component<P, S>>(node: ReactElement<P & WrappedComponentProps>, { context, childContextTypes, ...additionalOptions }?: {
|
|
6
|
-
context?: {} | undefined;
|
|
7
|
-
childContextTypes?: {} | undefined;
|
|
8
|
-
}) => ReactWrapper<P & WrappedComponentProps, S, C>;
|
|
9
|
-
export declare const shallowWithIntlContext: <P, S, C extends Component<P, S> = Component<P, S>>(node: ReactElement<P & WrappedComponentProps>, { context, ...additionalOptions }?: {
|
|
10
|
-
context?: {} | undefined;
|
|
11
|
-
}) => ShallowWrapper<P & WrappedComponentProps, S, C>;
|
|
12
|
-
export declare const mountWithIntlWrapper: (node: React.ReactElement) => ReactWrapper;
|