@atlaskit/media-test-helpers 28.9.0 → 29.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 +46 -0
- package/dist/cjs/I18nWrapper.js +3 -17
- package/dist/cjs/MockGlobalImage.js +1 -1
- package/dist/cjs/clipboardEventMocks.js +1 -1
- package/dist/cjs/collectionNames.js +1 -1
- package/dist/cjs/exampleMediaItems.js +1 -1
- package/dist/cjs/fakeMediaClient.js +1 -1
- package/dist/cjs/featureFlagsWrapper/helpers.js +1 -1
- package/dist/cjs/fileReader.js +1 -1
- package/dist/cjs/images.js +7 -7
- package/dist/cjs/index.js +272 -260
- package/dist/cjs/jestHelpers.js +1 -1
- package/dist/cjs/mediaClientErrors.js +1 -1
- package/dist/cjs/mediaClientProvider.js +1 -1
- package/dist/cjs/mediaPickerAuthProvider.js +1 -1
- package/dist/cjs/mediaPickerMocks.js +1 -1
- package/dist/cjs/mockData/index.js +19 -19
- package/dist/cjs/mockData/matchers.js +1 -1
- package/dist/cjs/mocks/database/collection-item.js +1 -1
- package/dist/cjs/mocks/database/index.js +2 -2
- package/dist/cjs/mocks/fileAndDirectoriesUtils.js +40 -34
- package/dist/cjs/mocks/media-mock.js +2 -1
- package/dist/cjs/mocks/websockets/messages.js +1 -1
- package/dist/cjs/mountWithIntlContext.js +62 -15
- package/dist/cjs/userAuthProvider.js +1 -1
- package/dist/cjs/utils/index.js +1 -1
- package/dist/cjs/utils/logging.js +1 -1
- package/dist/cjs/utils/mockData.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/waitUntil.js +1 -1
- package/dist/es2019/I18nWrapper.js +3 -16
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/mocks/fileAndDirectoriesUtils.js +6 -3
- package/dist/es2019/mountWithIntlContext.js +46 -13
- package/dist/es2019/version.json +1 -1
- package/dist/esm/I18nWrapper.js +3 -18
- package/dist/esm/index.js +1 -1
- package/dist/esm/mocks/fileAndDirectoriesUtils.js +39 -33
- package/dist/esm/mountWithIntlContext.js +54 -14
- package/dist/esm/version.json +1 -1
- package/dist/types/featureFlagsWrapper/dropdown.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/mountWithIntlContext.d.ts +12 -3
- package/package.json +4 -4
package/dist/esm/I18nWrapper.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
-
import React, { useState
|
|
4
|
-
import { IntlProvider
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { IntlProvider } from 'react-intl-next';
|
|
5
5
|
import LocaleSelect, { defaultLocales } from '@atlaskit/locale/LocaleSelect';
|
|
6
6
|
import { locales } from '@atlaskit/media-ui/locales';
|
|
7
7
|
|
|
@@ -18,17 +18,6 @@ var selectableLocales = defaultLocales.reduce(function (result, locale) {
|
|
|
18
18
|
|
|
19
19
|
return [].concat(_toConsumableArray(result), [locale]);
|
|
20
20
|
}, []);
|
|
21
|
-
|
|
22
|
-
function addAllLocaleData() {
|
|
23
|
-
Object.keys(locales).forEach(function (localeKey) {
|
|
24
|
-
var lang = localeKey.substring(0, 2);
|
|
25
|
-
|
|
26
|
-
var localeData = require("react-intl/locale-data/".concat(lang));
|
|
27
|
-
|
|
28
|
-
addLocaleData(localeData);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
21
|
export var I18NWrapper = function I18NWrapper(_ref) {
|
|
33
22
|
var children = _ref.children;
|
|
34
23
|
|
|
@@ -38,12 +27,8 @@ export var I18NWrapper = function I18NWrapper(_ref) {
|
|
|
38
27
|
}),
|
|
39
28
|
_useState2 = _slicedToArray(_useState, 2),
|
|
40
29
|
locale = _useState2[0],
|
|
41
|
-
setLocale = _useState2[1];
|
|
42
|
-
|
|
30
|
+
setLocale = _useState2[1];
|
|
43
31
|
|
|
44
|
-
useEffect(function () {
|
|
45
|
-
return addAllLocaleData();
|
|
46
|
-
}, []);
|
|
47
32
|
var lang = locale.value.substring(0, 2);
|
|
48
33
|
var messages = getMessages(locale.value);
|
|
49
34
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
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 { mountWithIntlContext } from './mountWithIntlContext';
|
|
24
|
+
export { mountWithIntlContext, mountWithIntlWrapper, shallowWithIntlContext } from './mountWithIntlContext';
|
|
25
25
|
export { fakeIntl } from './fakeI18n';
|
|
26
26
|
export { mockCanvas } from './mockCanvas';
|
|
27
27
|
export { default as KeyboardEventWithKeyCode } from './keyboardEventWithKeyCode';
|
|
@@ -14,46 +14,52 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
14
14
|
// Based on https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry
|
|
15
15
|
// Represents https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryReader
|
|
16
16
|
var createDataTransferItem = function createDataTransferItem(webkitGetAsEntryResult) {
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
return (// Using DataTransferItem constructor is illegal
|
|
18
|
+
{
|
|
19
|
+
getAsFile: function getAsFile() {
|
|
20
|
+
return null;
|
|
21
|
+
},
|
|
22
|
+
getAsString: function getAsString() {
|
|
23
|
+
return '';
|
|
24
|
+
},
|
|
25
|
+
kind: 'file',
|
|
26
|
+
type: '',
|
|
27
|
+
webkitGetAsEntry: function webkitGetAsEntry() {
|
|
28
|
+
return webkitGetAsEntryResult;
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
|
-
|
|
31
|
+
);
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
var createFileList = function createFileList(filesArray) {
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
return (// Using FileList constructor is illegal
|
|
36
|
+
_objectSpread(_objectSpread({}, filesArray), {}, {
|
|
37
|
+
length: filesArray.length,
|
|
38
|
+
item: function item(index) {
|
|
39
|
+
return filesArray[index];
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
);
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
var createDataTransferItemList = function createDataTransferItemList(itemsArray) {
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
return (// Using DataTransferItemList constructor is illegal
|
|
47
|
+
_objectSpread(_objectSpread({}, itemsArray), {}, {
|
|
48
|
+
length: itemsArray.length,
|
|
49
|
+
add: function add() {
|
|
50
|
+
return null;
|
|
51
|
+
},
|
|
52
|
+
clear: function clear() {
|
|
53
|
+
return null;
|
|
54
|
+
},
|
|
55
|
+
item: function item(index) {
|
|
56
|
+
return itemsArray[index];
|
|
57
|
+
},
|
|
58
|
+
remove: function remove() {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
);
|
|
57
63
|
};
|
|
58
64
|
|
|
59
65
|
var createDataTransfer = function createDataTransfer(files, items) {
|
|
@@ -1,29 +1,69 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
3
|
|
|
3
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
5
|
|
|
5
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
7
|
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { RawIntlProvider, createIntl, IntlProvider } from 'react-intl-next';
|
|
10
|
+
import { mount, shallow } from 'enzyme';
|
|
11
|
+
var mockIntl = createIntl({
|
|
12
|
+
locale: 'en'
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* When using React-Intl `injectIntl` on components, props.intl is required.
|
|
16
|
+
*/
|
|
9
17
|
|
|
18
|
+
function nodeWithIntlProp(node) {
|
|
19
|
+
var intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
20
|
+
return /*#__PURE__*/React.createElement(RawIntlProvider, {
|
|
21
|
+
value: intl
|
|
22
|
+
}, /*#__PURE__*/React.cloneElement(node, {
|
|
23
|
+
intl: intl
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
10
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
|
|
11
27
|
* and therefore fails the build:
|
|
12
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.
|
|
13
29
|
* TS is resolving enzyme's usage of react to react-transition-group???
|
|
14
30
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export var mountWithIntlContext = function mountWithIntlContext(node) {
|
|
34
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
35
|
+
|
|
36
|
+
var _ref$context = _ref.context,
|
|
37
|
+
context = _ref$context === void 0 ? {} : _ref$context,
|
|
38
|
+
_ref$childContextType = _ref.childContextTypes,
|
|
39
|
+
childContextTypes = _ref$childContextType === void 0 ? {} : _ref$childContextType,
|
|
40
|
+
additionalOptions = _objectWithoutProperties(_ref, ["context", "childContextTypes"]);
|
|
41
|
+
|
|
42
|
+
var intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
43
|
+
return mount(nodeWithIntlProp(node), _objectSpread({
|
|
44
|
+
context: _objectSpread({
|
|
45
|
+
intl: intl
|
|
46
|
+
}, context)
|
|
47
|
+
}, additionalOptions));
|
|
48
|
+
};
|
|
49
|
+
export var shallowWithIntlContext = function shallowWithIntlContext(node) {
|
|
50
|
+
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
51
|
+
|
|
52
|
+
var _ref2$context = _ref2.context,
|
|
53
|
+
context = _ref2$context === void 0 ? {} : _ref2$context,
|
|
54
|
+
additionalOptions = _objectWithoutProperties(_ref2, ["context"]);
|
|
55
|
+
|
|
56
|
+
var intl = !!node.props.intl ? node.props.intl : mockIntl;
|
|
57
|
+
return shallow(nodeWithIntlProp(node), _objectSpread({
|
|
22
58
|
context: _objectSpread({
|
|
23
59
|
intl: intl
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
60
|
+
}, context)
|
|
61
|
+
}, additionalOptions));
|
|
62
|
+
};
|
|
63
|
+
export var mountWithIntlWrapper = function mountWithIntlWrapper(node) {
|
|
64
|
+
return mount( /*#__PURE__*/React.createElement(function (props) {
|
|
65
|
+
return /*#__PURE__*/React.createElement(IntlProvider, {
|
|
66
|
+
locale: "en"
|
|
67
|
+
}, /*#__PURE__*/React.cloneElement(node, _objectSpread({}, props)));
|
|
68
|
+
}));
|
|
29
69
|
};
|
package/dist/esm/version.json
CHANGED
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 { mountWithIntlContext } from './mountWithIntlContext';
|
|
30
|
+
export { mountWithIntlContext, mountWithIntlWrapper, shallowWithIntlContext, } from './mountWithIntlContext';
|
|
31
31
|
export { fakeIntl } from './fakeI18n';
|
|
32
32
|
export { mockCanvas } from './mockCanvas';
|
|
33
33
|
export { default as KeyboardEventWithKeyCode } from './keyboardEventWithKeyCode';
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
+
import { ReactWrapper, ShallowWrapper } from 'enzyme';
|
|
4
|
+
import { ReactElement } from 'react';
|
|
5
|
+
export declare const mountWithIntlContext: <P, S, C extends React.Component<P, S, any> = React.Component<P, S, any>>(node: React.ReactElement<P & WrappedComponentProps<"intl">, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>, { context, childContextTypes, ...additionalOptions }?: {
|
|
6
|
+
context?: {} | undefined;
|
|
7
|
+
childContextTypes?: {} | undefined;
|
|
8
|
+
}) => ReactWrapper<P & WrappedComponentProps<"intl">, S, C>;
|
|
9
|
+
export declare const shallowWithIntlContext: <P, S, C extends React.Component<P, S, any> = React.Component<P, S, any>>(node: React.ReactElement<P & WrappedComponentProps<"intl">, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>, { context, ...additionalOptions }?: {
|
|
10
|
+
context?: {} | undefined;
|
|
11
|
+
}) => ShallowWrapper<P & WrappedComponentProps<"intl">, S, C>;
|
|
12
|
+
export declare const mountWithIntlWrapper: (node: React.ReactElement) => ReactWrapper;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-test-helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "29.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/"
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@atlaskit/media-client": "^14.3.0",
|
|
27
27
|
"@atlaskit/media-common": "^2.10.0",
|
|
28
28
|
"@atlaskit/media-core": "^32.2.0",
|
|
29
|
-
"@atlaskit/media-picker": "^
|
|
30
|
-
"@atlaskit/media-ui": "^
|
|
29
|
+
"@atlaskit/media-picker": "^59.0.0",
|
|
30
|
+
"@atlaskit/media-ui": "^18.0.0",
|
|
31
31
|
"@atlaskit/popup": "^1.1.0",
|
|
32
32
|
"@atlaskit/textfield": "^5.0.1",
|
|
33
33
|
"@atlaskit/tooltip": "^17.5.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"kakapo": "^4.0.6",
|
|
38
38
|
"lodash": "^4.17.15",
|
|
39
39
|
"mock-socket": "^9.0.3",
|
|
40
|
-
"react-intl": "
|
|
40
|
+
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
41
41
|
"react-redux": "^5.1.2",
|
|
42
42
|
"styled-components": "^3.2.6",
|
|
43
43
|
"uuid": "^3.1.0",
|