@atlaskit/media-test-helpers 30.1.1 → 30.1.2
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 +6 -0
- package/dist/cjs/I18nWrapper.js +8 -24
- package/dist/cjs/MockGlobalImage.js +0 -16
- package/dist/cjs/authProvider.js +0 -18
- package/dist/cjs/await-error.js +0 -10
- package/dist/cjs/clipboardEventMocks.js +6 -39
- package/dist/cjs/createMouseEvent.js +4 -8
- package/dist/cjs/createTouchEvent.js +0 -2
- package/dist/cjs/docs-content-tabs.js +1 -14
- package/dist/cjs/example-mediaFeatureFlags.js +0 -7
- package/dist/cjs/exampleMediaItems.js +6 -7
- package/dist/cjs/fakeI18n.js +2 -4
- package/dist/cjs/fakeMediaClient.js +5 -18
- package/dist/cjs/featureFlagsWrapper/dropdown.js +12 -46
- package/dist/cjs/featureFlagsWrapper/helpers.js +0 -14
- package/dist/cjs/featureFlagsWrapper/index.js +5 -19
- package/dist/cjs/fileReader.js +0 -28
- package/dist/cjs/fileStateFactory/createFileState.js +9 -27
- package/dist/cjs/fileStateFactory/factory.js +7 -44
- package/dist/cjs/fileStateFactory/helpers.js +10 -23
- package/dist/cjs/fileStateFactory/index.js +0 -3
- package/dist/cjs/flushPromises.js +0 -2
- package/dist/cjs/getAuthFromContextProvider.js +0 -9
- package/dist/cjs/getJest.js +3 -5
- package/dist/cjs/globalEventEmitterListeners.js +0 -8
- package/dist/cjs/images.js +0 -6
- package/dist/cjs/index.js +0 -42
- package/dist/cjs/jestHelpers.js +0 -20
- package/dist/cjs/keyboardEventWithKeyCode.js +0 -18
- package/dist/cjs/mediaClientErrors.js +0 -11
- package/dist/cjs/mediaClientProvider.js +1 -17
- package/dist/cjs/mediaPickerAuthProvider.js +5 -21
- package/dist/cjs/mockCanvas.js +0 -4
- package/dist/cjs/mockData/handlers/copyWithToken.js +0 -14
- package/dist/cjs/mockData/handlers/getFile.js +0 -8
- package/dist/cjs/mockData/handlers/getFileImage.js +0 -9
- package/dist/cjs/mockData/handlers/index.js +0 -5
- package/dist/cjs/mockData/handlers/tenantAuth.js +0 -6
- package/dist/cjs/mockData/handlers/userCollectionFetch.js +0 -11
- package/dist/cjs/mockData/index.js +0 -9
- package/dist/cjs/mockData/matchers.js +0 -11
- package/dist/cjs/mockData/utils.js +10 -10
- package/dist/cjs/mockLoadImage.js +2 -14
- package/dist/cjs/mocks/database/chunk.js +0 -3
- package/dist/cjs/mocks/database/collection-item.js +14 -23
- package/dist/cjs/mocks/database/collection.js +0 -2
- package/dist/cjs/mocks/database/index.js +5 -23
- package/dist/cjs/mocks/database/upload.js +0 -6
- package/dist/cjs/mocks/fileAndDirectoriesUtils.js +12 -20
- package/dist/cjs/mocks/media-mock.js +14 -45
- package/dist/cjs/mocks/routers/api-router.js +78 -162
- package/dist/cjs/mocks/routers/index.js +0 -2
- package/dist/cjs/mocks/routers/media-playground-router.js +0 -3
- package/dist/cjs/mocks/websockets/index.js +0 -1
- package/dist/cjs/mocks/websockets/messages.js +0 -9
- package/dist/cjs/mocks/websockets/remote-upload-server.js +19 -45
- package/dist/cjs/mountWithIntlContext.js +9 -27
- package/dist/cjs/nextTick.js +0 -4
- package/dist/cjs/renderWithIntl.js +0 -6
- package/dist/cjs/story-list.js +4 -22
- package/dist/cjs/story-styles.js +0 -6
- package/dist/cjs/styled.js +0 -6
- package/dist/cjs/timeoutPromise.js +0 -1
- package/dist/cjs/ufoLogger.js +0 -7
- package/dist/cjs/utils/index.js +2 -11
- package/dist/cjs/utils/logging.js +11 -12
- package/dist/cjs/utils/mockData.js +5 -19
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/waitUntil.js +2 -10
- package/dist/es2019/I18nWrapper.js +2 -4
- package/dist/es2019/MockGlobalImage.js +0 -3
- package/dist/es2019/authProvider.js +2 -5
- package/dist/es2019/clipboardEventMocks.js +12 -26
- package/dist/es2019/createMouseEvent.js +0 -2
- package/dist/es2019/docs-content-tabs.js +1 -3
- package/dist/es2019/example-mediaFeatureFlags.js +3 -2
- package/dist/es2019/exampleMediaItems.js +8 -3
- package/dist/es2019/fakeI18n.js +2 -1
- package/dist/es2019/fakeMediaClient.js +0 -1
- package/dist/es2019/featureFlagsWrapper/dropdown.js +0 -10
- package/dist/es2019/featureFlagsWrapper/helpers.js +2 -1
- package/dist/es2019/featureFlagsWrapper/index.js +2 -7
- package/dist/es2019/fileReader.js +0 -17
- package/dist/es2019/fileStateFactory/createFileState.js +6 -14
- package/dist/es2019/fileStateFactory/factory.js +4 -15
- package/dist/es2019/fileStateFactory/helpers.js +2 -7
- package/dist/es2019/getJest.js +3 -6
- package/dist/es2019/globalEventEmitterListeners.js +0 -3
- package/dist/es2019/images.js +2 -1
- package/dist/es2019/keyboardEventWithKeyCode.js +0 -5
- package/dist/es2019/mediaClientErrors.js +2 -1
- package/dist/es2019/mediaClientProvider.js +1 -1
- package/dist/es2019/mediaPickerAuthProvider.js +2 -5
- package/dist/es2019/mockData/handlers/copyWithToken.js +0 -2
- package/dist/es2019/mockData/handlers/getFile.js +0 -3
- package/dist/es2019/mockData/handlers/getFileImage.js +0 -3
- package/dist/es2019/mockData/handlers/tenantAuth.js +0 -2
- package/dist/es2019/mockData/handlers/userCollectionFetch.js +0 -2
- package/dist/es2019/mockData/index.js +0 -2
- package/dist/es2019/mockData/utils.js +10 -6
- package/dist/es2019/mockLoadImage.js +4 -2
- package/dist/es2019/mocks/database/index.js +0 -2
- package/dist/es2019/mocks/fileAndDirectoriesUtils.js +20 -14
- package/dist/es2019/mocks/media-mock.js +4 -16
- package/dist/es2019/mocks/routers/api-router.js +13 -45
- package/dist/es2019/mocks/websockets/remote-upload-server.js +11 -14
- package/dist/es2019/mountWithIntlContext.js +4 -4
- package/dist/es2019/story-list.js +0 -1
- package/dist/es2019/ufoLogger.js +0 -1
- package/dist/es2019/utils/index.js +0 -2
- package/dist/es2019/utils/logging.js +4 -4
- package/dist/es2019/utils/mockData.js +5 -3
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/waitUntil.js +0 -1
- package/dist/esm/I18nWrapper.js +8 -12
- package/dist/esm/MockGlobalImage.js +0 -10
- package/dist/esm/authProvider.js +0 -10
- package/dist/esm/await-error.js +0 -6
- package/dist/esm/clipboardEventMocks.js +15 -39
- package/dist/esm/createMouseEvent.js +4 -6
- package/dist/esm/docs-content-tabs.js +2 -5
- package/dist/esm/example-mediaFeatureFlags.js +0 -3
- package/dist/esm/exampleMediaItems.js +8 -3
- package/dist/esm/fakeI18n.js +2 -1
- package/dist/esm/fakeMediaClient.js +5 -8
- package/dist/esm/featureFlagsWrapper/dropdown.js +12 -30
- package/dist/esm/featureFlagsWrapper/helpers.js +0 -3
- package/dist/esm/featureFlagsWrapper/index.js +5 -12
- package/dist/esm/fileReader.js +0 -28
- package/dist/esm/fileStateFactory/createFileState.js +9 -22
- package/dist/esm/fileStateFactory/factory.js +7 -41
- package/dist/esm/fileStateFactory/helpers.js +10 -18
- package/dist/esm/getAuthFromContextProvider.js +0 -3
- package/dist/esm/getJest.js +3 -3
- package/dist/esm/globalEventEmitterListeners.js +0 -3
- package/dist/esm/images.js +2 -1
- package/dist/esm/jestHelpers.js +0 -2
- package/dist/esm/keyboardEventWithKeyCode.js +0 -10
- package/dist/esm/mediaClientErrors.js +0 -3
- package/dist/esm/mediaClientProvider.js +1 -1
- package/dist/esm/mediaPickerAuthProvider.js +5 -12
- package/dist/esm/mockData/handlers/copyWithToken.js +0 -4
- package/dist/esm/mockData/handlers/getFile.js +0 -3
- package/dist/esm/mockData/handlers/getFileImage.js +0 -3
- package/dist/esm/mockData/handlers/tenantAuth.js +0 -2
- package/dist/esm/mockData/handlers/userCollectionFetch.js +0 -5
- package/dist/esm/mockData/index.js +0 -2
- package/dist/esm/mockData/utils.js +10 -6
- package/dist/esm/mockLoadImage.js +2 -4
- package/dist/esm/mocks/database/collection-item.js +14 -15
- package/dist/esm/mocks/database/index.js +5 -7
- package/dist/esm/mocks/fileAndDirectoriesUtils.js +12 -13
- package/dist/esm/mocks/media-mock.js +14 -26
- package/dist/esm/mocks/routers/api-router.js +78 -144
- package/dist/esm/mocks/websockets/remote-upload-server.js +19 -24
- package/dist/esm/mountWithIntlContext.js +9 -17
- package/dist/esm/story-list.js +4 -12
- package/dist/esm/story-styles.js +0 -2
- package/dist/esm/styled.js +0 -2
- package/dist/esm/ufoLogger.js +0 -4
- package/dist/esm/utils/index.js +2 -5
- package/dist/esm/utils/logging.js +11 -11
- package/dist/esm/utils/mockData.js +5 -3
- package/dist/esm/version.json +1 -1
- package/dist/esm/waitUntil.js +2 -6
- package/package.json +4 -4
|
@@ -6,17 +6,11 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
-
|
|
12
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
-
|
|
14
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
15
|
-
|
|
16
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
17
|
-
|
|
18
13
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
-
|
|
20
14
|
import { tallImage, dataURItoBlob } from '..';
|
|
21
15
|
import { MediaClient, createMediaSubject } from '@atlaskit/media-client';
|
|
22
16
|
import { createFileState } from './createFileState';
|
|
@@ -24,25 +18,17 @@ import { createFileDetails } from './helpers';
|
|
|
24
18
|
import { sleep } from '../nextTick';
|
|
25
19
|
export var MediaClientMock = /*#__PURE__*/function (_MediaClient) {
|
|
26
20
|
_inherits(MediaClientMock, _MediaClient);
|
|
27
|
-
|
|
28
21
|
var _super = _createSuper(MediaClientMock);
|
|
29
|
-
|
|
30
22
|
function MediaClientMock(observable, mediaClientConfig, featureFlags) {
|
|
31
23
|
var _this;
|
|
32
|
-
|
|
33
24
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
34
|
-
|
|
35
25
|
_classCallCheck(this, MediaClientMock);
|
|
36
|
-
|
|
37
26
|
_this = _super.call(this, mediaClientConfig, featureFlags);
|
|
38
|
-
|
|
39
27
|
_defineProperty(_assertThisInitialized(_this), "updateObserbable", function (newObservable) {
|
|
40
28
|
_this.observable = newObservable;
|
|
41
29
|
});
|
|
42
|
-
|
|
43
30
|
_defineProperty(_assertThisInitialized(_this), "getImage", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
44
31
|
var _this$options$getImag, getImageDelay;
|
|
45
|
-
|
|
46
32
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
47
33
|
while (1) {
|
|
48
34
|
switch (_context.prev = _context.next) {
|
|
@@ -50,10 +36,8 @@ export var MediaClientMock = /*#__PURE__*/function (_MediaClient) {
|
|
|
50
36
|
_this$options$getImag = _this.options.getImageDelay, getImageDelay = _this$options$getImag === void 0 ? 0 : _this$options$getImag;
|
|
51
37
|
_context.next = 3;
|
|
52
38
|
return sleep(getImageDelay);
|
|
53
|
-
|
|
54
39
|
case 3:
|
|
55
40
|
return _context.abrupt("return", dataURItoBlob(tallImage));
|
|
56
|
-
|
|
57
41
|
case 4:
|
|
58
42
|
case "end":
|
|
59
43
|
return _context.stop();
|
|
@@ -61,21 +45,16 @@ export var MediaClientMock = /*#__PURE__*/function (_MediaClient) {
|
|
|
61
45
|
}
|
|
62
46
|
}, _callee);
|
|
63
47
|
})));
|
|
64
|
-
|
|
65
48
|
_defineProperty(_assertThisInitialized(_this), "mockFileFetcher", function () {
|
|
66
49
|
_this.file.getFileState = function () {
|
|
67
50
|
return _this.observable;
|
|
68
51
|
};
|
|
69
52
|
});
|
|
70
|
-
|
|
71
53
|
_this.observable = observable;
|
|
72
54
|
_this.options = options;
|
|
73
|
-
|
|
74
55
|
_this.mockFileFetcher();
|
|
75
|
-
|
|
76
56
|
return _this;
|
|
77
57
|
}
|
|
78
|
-
|
|
79
58
|
return _createClass(MediaClientMock);
|
|
80
59
|
}(MediaClient);
|
|
81
60
|
var mockConfig = {
|
|
@@ -90,7 +69,6 @@ var mockConfig = {
|
|
|
90
69
|
token: 'some-token',
|
|
91
70
|
baseUrl: 'some-url'
|
|
92
71
|
});
|
|
93
|
-
|
|
94
72
|
case 1:
|
|
95
73
|
case "end":
|
|
96
74
|
return _context2.stop();
|
|
@@ -98,40 +76,32 @@ var mockConfig = {
|
|
|
98
76
|
}
|
|
99
77
|
}, _callee2);
|
|
100
78
|
}));
|
|
101
|
-
|
|
102
79
|
function authProvider() {
|
|
103
80
|
return _authProvider.apply(this, arguments);
|
|
104
81
|
}
|
|
105
|
-
|
|
106
82
|
return authProvider;
|
|
107
83
|
}()
|
|
108
84
|
};
|
|
109
|
-
|
|
110
85
|
/**
|
|
111
86
|
* A fake Media Client that provides a backdoor to inject
|
|
112
87
|
* simulated file states. With this class, we can test several scenarios
|
|
113
88
|
* without having to recreate them all in the backend.
|
|
114
89
|
*/
|
|
115
|
-
export var FileStateFactory = /*#__PURE__*/_createClass(function FileStateFactory(
|
|
90
|
+
export var FileStateFactory = /*#__PURE__*/_createClass(function FileStateFactory(_identifier) {
|
|
116
91
|
var _this2 = this;
|
|
117
|
-
|
|
118
92
|
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
93
|
+
_fileDetails = _ref2.fileDetails,
|
|
94
|
+
_ref2$mediaClientConf = _ref2.mediaClientConfig,
|
|
95
|
+
mediaClientConfig = _ref2$mediaClientConf === void 0 ? mockConfig : _ref2$mediaClientConf,
|
|
96
|
+
featureFlags = _ref2.featureFlags,
|
|
97
|
+
mediaClientMockOptions = _ref2.mediaClientMockOptions;
|
|
125
98
|
_classCallCheck(this, FileStateFactory);
|
|
126
|
-
|
|
127
99
|
_defineProperty(this, "updateIdentifier", function (identifier, fileDetails) {
|
|
128
100
|
_this2.identifier = identifier;
|
|
129
101
|
_this2.fileDetails = fileDetails || createFileDetails(_this2.identifier.id);
|
|
130
102
|
_this2.observable = createMediaSubject();
|
|
131
|
-
|
|
132
103
|
_this2.mediaClient.updateObserbable(_this2.observable);
|
|
133
104
|
});
|
|
134
|
-
|
|
135
105
|
_defineProperty(this, "subscription", {
|
|
136
106
|
next: function next(fileState) {
|
|
137
107
|
_this2.observable.next(fileState);
|
|
@@ -140,22 +110,18 @@ export var FileStateFactory = /*#__PURE__*/_createClass(function FileStateFactor
|
|
|
140
110
|
_this2.observable.error(_error);
|
|
141
111
|
}
|
|
142
112
|
});
|
|
143
|
-
|
|
144
113
|
_defineProperty(this, "createFileState", function (status, options) {
|
|
145
114
|
return createFileState(_this2.identifier.id, status, _objectSpread(_objectSpread({}, options), {}, {
|
|
146
115
|
fileDetails: (options === null || options === void 0 ? void 0 : options.fileDetails) || _this2.fileDetails
|
|
147
116
|
}));
|
|
148
117
|
});
|
|
149
|
-
|
|
150
118
|
_defineProperty(this, "next", function (status, options) {
|
|
151
119
|
_this2.subscription.next(_this2.createFileState(status, options));
|
|
152
120
|
});
|
|
153
|
-
|
|
154
121
|
_defineProperty(this, "error", function (error) {
|
|
155
122
|
_this2.subscription.error(error);
|
|
156
123
|
});
|
|
157
|
-
|
|
158
|
-
this.identifier = identifier;
|
|
124
|
+
this.identifier = _identifier;
|
|
159
125
|
this.fileDetails = _fileDetails || createFileDetails(this.identifier.id);
|
|
160
126
|
this.observable = createMediaSubject();
|
|
161
127
|
this.mediaClient = new MediaClientMock(this.observable, mediaClientConfig, featureFlags, mediaClientMockOptions);
|
|
@@ -5,8 +5,9 @@ export var defaultFileDetails = {
|
|
|
5
5
|
mimeType: 'image/png',
|
|
6
6
|
name: 'file-name.png',
|
|
7
7
|
size: 1
|
|
8
|
-
};
|
|
8
|
+
};
|
|
9
9
|
|
|
10
|
+
// min inclusive / max exclusive
|
|
10
11
|
function random() {
|
|
11
12
|
var min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
12
13
|
var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10000;
|
|
@@ -15,18 +16,15 @@ function random() {
|
|
|
15
16
|
var result = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
16
17
|
return result;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
19
|
var getRandomElem = function getRandomElem(arr) {
|
|
20
20
|
return arr[Math.floor(Math.random() * arr.length)];
|
|
21
21
|
};
|
|
22
|
-
|
|
23
22
|
export var createIdentifier = function createIdentifier() {
|
|
24
23
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
_ref$collectionName = _ref.collectionName,
|
|
25
|
+
collectionName = _ref$collectionName === void 0 ? "collection-".concat(random()) : _ref$collectionName,
|
|
26
|
+
_ref$occurrenceKey = _ref.occurrenceKey,
|
|
27
|
+
occurrenceKey = _ref$occurrenceKey === void 0 ? "occurrence-".concat(random()) : _ref$occurrenceKey;
|
|
30
28
|
return {
|
|
31
29
|
mediaItemType: 'file',
|
|
32
30
|
id: uuidv4(),
|
|
@@ -34,12 +32,10 @@ export var createIdentifier = function createIdentifier() {
|
|
|
34
32
|
occurrenceKey: occurrenceKey
|
|
35
33
|
};
|
|
36
34
|
};
|
|
37
|
-
|
|
38
35
|
var generateFileName = function generateFileName(extension) {
|
|
39
36
|
var fileNames = ['quick-and-dirty', 'quality-time', 'down-for-the-count', 'hard-pill-to-swallow', 'between-a-rock-and-a-hard-place', 'fish-out-of-water', 'top-drawer', 'like-father-like-son', 'mountain-out-of-a-molehill', 'under-your-nose', 'a-chip-on-your-shoulder', 'hit-below-the-belt'];
|
|
40
37
|
return "".concat(getRandomElem(fileNames), ".").concat(extension);
|
|
41
38
|
};
|
|
42
|
-
|
|
43
39
|
var mediaTypesDetails = {
|
|
44
40
|
image: {
|
|
45
41
|
ext: 'png',
|
|
@@ -67,24 +63,20 @@ var mediaTypesDetails = {
|
|
|
67
63
|
}
|
|
68
64
|
};
|
|
69
65
|
var mediaTypes = Object.keys(mediaTypesDetails);
|
|
70
|
-
|
|
71
66
|
var generateMediaTypeDetails = function generateMediaTypeDetails(mediaType) {
|
|
72
67
|
var _mediaTypesDetails$me = mediaTypesDetails[mediaType],
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
mimeType = _mediaTypesDetails$me.mimeType,
|
|
69
|
+
ext = _mediaTypesDetails$me.ext;
|
|
75
70
|
return {
|
|
76
71
|
mimeType: mimeType,
|
|
77
72
|
name: generateFileName(ext)
|
|
78
73
|
};
|
|
79
74
|
};
|
|
80
|
-
|
|
81
75
|
export var createFileDetails = function createFileDetails(id) {
|
|
82
76
|
var mediaType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getRandomElem(mediaTypes);
|
|
83
|
-
|
|
84
77
|
var _generateMediaTypeDet = generateMediaTypeDetails(mediaType),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
mimeType = _generateMediaTypeDet.mimeType,
|
|
79
|
+
name = _generateMediaTypeDet.name;
|
|
88
80
|
return {
|
|
89
81
|
id: id,
|
|
90
82
|
createdAt: random(),
|
|
@@ -30,11 +30,9 @@ export var getAuthFromContextProvider = /*#__PURE__*/function () {
|
|
|
30
30
|
body: body,
|
|
31
31
|
headers: headers
|
|
32
32
|
});
|
|
33
|
-
|
|
34
33
|
case 7:
|
|
35
34
|
response = _context.sent;
|
|
36
35
|
return _context.abrupt("return", response.json());
|
|
37
|
-
|
|
38
36
|
case 9:
|
|
39
37
|
case "end":
|
|
40
38
|
return _context.stop();
|
|
@@ -42,7 +40,6 @@ export var getAuthFromContextProvider = /*#__PURE__*/function () {
|
|
|
42
40
|
}
|
|
43
41
|
}, _callee);
|
|
44
42
|
}));
|
|
45
|
-
|
|
46
43
|
return function getAuthFromContextProvider() {
|
|
47
44
|
return _ref.apply(this, arguments);
|
|
48
45
|
};
|
package/dist/esm/getJest.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Mock the bare minimum of jest used within `media-test-helpers`.
|
|
2
2
|
// Ideally this is not required in the future when functions are no longer used in Examples
|
|
3
3
|
// as they should only be used in unit tests.
|
|
4
|
+
|
|
4
5
|
var mockStub = function mockStub() {
|
|
5
6
|
return Object.assign(function () {}, {
|
|
6
7
|
mockReturnValue: function mockReturnValue(value) {},
|
|
@@ -8,7 +9,6 @@ var mockStub = function mockStub() {
|
|
|
8
9
|
mockResolvedValue: function mockResolvedValue(value) {}
|
|
9
10
|
});
|
|
10
11
|
};
|
|
11
|
-
|
|
12
12
|
var mockJest = function mockJest() {
|
|
13
13
|
// eslint-disable-next-line no-console
|
|
14
14
|
console.warn('Using mock jest. Please remove references to media-test-helpers in non-test code.');
|
|
@@ -23,9 +23,9 @@ var mockJest = function mockJest() {
|
|
|
23
23
|
requireActual: function requireActual() {},
|
|
24
24
|
doMock: function doMock() {}
|
|
25
25
|
};
|
|
26
|
-
};
|
|
27
|
-
|
|
26
|
+
};
|
|
28
27
|
|
|
28
|
+
// ED-15806 Required as some examples currently use test modules and complain about not having `jest`.
|
|
29
29
|
export default (function () {
|
|
30
30
|
return typeof jest === 'undefined' ? mockJest() : jest;
|
|
31
31
|
});
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { globalMediaEventEmitter } from '@atlaskit/media-client';
|
|
2
|
-
|
|
3
2
|
var fileAddedListener = function fileAddedListener(fileState) {
|
|
4
3
|
// eslint-disable-next-line no-console
|
|
5
4
|
console.log('file-added -> globalMediaEventEmitter', {
|
|
6
5
|
fileState: fileState
|
|
7
6
|
});
|
|
8
7
|
};
|
|
9
|
-
|
|
10
8
|
var attachmentViewedListener = function attachmentViewedListener(payload) {
|
|
11
9
|
// eslint-disable-next-line no-console
|
|
12
10
|
console.log('media-viewed -> globalMediaEventEmitter', {
|
|
13
11
|
payload: payload
|
|
14
12
|
});
|
|
15
13
|
};
|
|
16
|
-
|
|
17
14
|
export var addGlobalEventEmitterListeners = function addGlobalEventEmitterListeners() {
|
|
18
15
|
globalMediaEventEmitter.off('file-added', fileAddedListener);
|
|
19
16
|
globalMediaEventEmitter.off('media-viewed', attachmentViewedListener);
|
package/dist/esm/images.js
CHANGED
|
@@ -2,6 +2,7 @@ export { tallImage } from './dataURIs/tallImageURI';
|
|
|
2
2
|
export { smallImage } from './dataURIs/smallImageURI';
|
|
3
3
|
export { smallTransparentImage } from './dataURIs/smallTransparentImageURI';
|
|
4
4
|
export { wideImage } from './dataURIs/wideImageURI';
|
|
5
|
-
export { wideTransparentImage } from './dataURIs/wideTransparentImageURI';
|
|
5
|
+
export { wideTransparentImage } from './dataURIs/wideTransparentImageURI';
|
|
6
6
|
|
|
7
|
+
// image urls
|
|
7
8
|
export var remoteImage = 'https://mediaviewer-examples.s3-ap-southeast-2.amazonaws.com/image/image.jpg';
|
package/dist/esm/jestHelpers.js
CHANGED
|
@@ -19,11 +19,9 @@ export var expectToEqual = function expectToEqual(actual, expected) {
|
|
|
19
19
|
};
|
|
20
20
|
export var expectConstructorToHaveBeenCalledWith = function expectConstructorToHaveBeenCalledWith(func, expectedArgs) {
|
|
21
21
|
var _expect;
|
|
22
|
-
|
|
23
22
|
return (_expect = expect(func)).toHaveBeenCalledWith.apply(_expect, _toConsumableArray(expectedArgs));
|
|
24
23
|
};
|
|
25
24
|
export var expectFunctionToHaveBeenCalledWith = function expectFunctionToHaveBeenCalledWith(func, expectedArgs) {
|
|
26
25
|
var _expect2;
|
|
27
|
-
|
|
28
26
|
return (_expect2 = expect(func)).toHaveBeenCalledWith.apply(_expect2, _toConsumableArray(expectedArgs));
|
|
29
27
|
};
|
|
@@ -3,30 +3,20 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
3
3
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
5
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
6
|
-
|
|
7
6
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
|
|
9
7
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
|
|
11
8
|
import * as exenv from 'exenv';
|
|
12
|
-
|
|
13
9
|
var FakeKeyboardEvent = /*#__PURE__*/_createClass(function FakeKeyboardEvent(_, __) {
|
|
14
10
|
_classCallCheck(this, FakeKeyboardEvent);
|
|
15
11
|
});
|
|
16
|
-
|
|
17
12
|
var KeyboardEventWithKeyCode = /*#__PURE__*/function (_ref) {
|
|
18
13
|
_inherits(KeyboardEventWithKeyCode, _ref);
|
|
19
|
-
|
|
20
14
|
var _super = _createSuper(KeyboardEventWithKeyCode);
|
|
21
|
-
|
|
22
15
|
function KeyboardEventWithKeyCode(type, options) {
|
|
23
16
|
_classCallCheck(this, KeyboardEventWithKeyCode);
|
|
24
|
-
|
|
25
17
|
return _super.call(this, type, options);
|
|
26
18
|
}
|
|
27
|
-
|
|
28
19
|
return _createClass(KeyboardEventWithKeyCode);
|
|
29
20
|
}(exenv.canUseDOM ? KeyboardEvent : Object);
|
|
30
|
-
|
|
31
21
|
var Class = exenv.canUseDOM ? KeyboardEventWithKeyCode : FakeKeyboardEvent;
|
|
32
22
|
export default Class;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
import { RequestError, PollingError, MediaStoreError } from '@atlaskit/media-client';
|
|
8
5
|
export var createRateLimitedError = function createRateLimitedError() {
|
|
9
6
|
var metadata = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -11,13 +11,13 @@ export var defaultParams = {
|
|
|
11
11
|
var defaultAuthParameter = {
|
|
12
12
|
authType: 'client'
|
|
13
13
|
};
|
|
14
|
+
|
|
14
15
|
/**
|
|
15
16
|
* Creates and returns `MediaClient` (from `media-client`) based on the data provided in parameter object.
|
|
16
17
|
*
|
|
17
18
|
* @param {AuthParameter} authParameter specifies serviceName and whatever auth should be done with clientId or asapIssuer
|
|
18
19
|
* @returns {Context}
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
21
|
export var createStorybookMediaClient = function createStorybookMediaClient() {
|
|
22
22
|
var authParameter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultAuthParameter;
|
|
23
23
|
return new MediaClient(createStorybookMediaClientConfig(authParameter));
|
|
@@ -22,15 +22,14 @@ var accessUrns = {
|
|
|
22
22
|
'urn:filestore:file:*': ['read', 'update']
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
|
|
26
25
|
var requestAuthProvider = /*#__PURE__*/function () {
|
|
27
26
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(authEnvironment, collectionName) {
|
|
28
27
|
var env,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
url,
|
|
29
|
+
body,
|
|
30
|
+
headers,
|
|
31
|
+
response,
|
|
32
|
+
_args = arguments;
|
|
34
33
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
35
34
|
while (1) {
|
|
36
35
|
switch (_context.prev = _context.next) {
|
|
@@ -49,11 +48,9 @@ var requestAuthProvider = /*#__PURE__*/function () {
|
|
|
49
48
|
body: body,
|
|
50
49
|
headers: headers
|
|
51
50
|
});
|
|
52
|
-
|
|
53
51
|
case 8:
|
|
54
52
|
response = _context.sent;
|
|
55
53
|
return _context.abrupt("return", response.json());
|
|
56
|
-
|
|
57
54
|
case 10:
|
|
58
55
|
case "end":
|
|
59
56
|
return _context.stop();
|
|
@@ -61,12 +58,10 @@ var requestAuthProvider = /*#__PURE__*/function () {
|
|
|
61
58
|
}
|
|
62
59
|
}, _callee);
|
|
63
60
|
}));
|
|
64
|
-
|
|
65
61
|
return function requestAuthProvider(_x, _x2) {
|
|
66
62
|
return _ref.apply(this, arguments);
|
|
67
63
|
};
|
|
68
64
|
}();
|
|
69
|
-
|
|
70
65
|
export var mediaPickerAuthProvider = function mediaPickerAuthProvider() {
|
|
71
66
|
var authEnvironment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asap';
|
|
72
67
|
var env = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -74,11 +69,9 @@ export var mediaPickerAuthProvider = function mediaPickerAuthProvider() {
|
|
|
74
69
|
var collectionName = context && context.collectionName || defaultCollectionName;
|
|
75
70
|
authEnvironment = authEnvironment === 'asap' ? 'asap' : '';
|
|
76
71
|
var cacheKey = "".concat(collectionName, ":").concat(authEnvironment);
|
|
77
|
-
|
|
78
72
|
if (!cachedAuths[cacheKey]) {
|
|
79
73
|
cachedAuths[cacheKey] = requestAuthProvider(authEnvironment, collectionName, env);
|
|
80
74
|
}
|
|
81
|
-
|
|
82
75
|
return cachedAuths[cacheKey];
|
|
83
76
|
};
|
|
84
77
|
};
|
|
@@ -31,13 +31,10 @@ export var copyWithToken = function copyWithToken(context) {
|
|
|
31
31
|
})
|
|
32
32
|
};
|
|
33
33
|
});
|
|
34
|
-
|
|
35
34
|
var availableFiles = _toConsumableArray(context().userContext.collection);
|
|
36
|
-
|
|
37
35
|
var matchingDataItem = data.reduce(function (ret, dataItem) {
|
|
38
36
|
return exactMatch(req, dataItem) ? dataItem : ret;
|
|
39
37
|
}, undefined);
|
|
40
|
-
|
|
41
38
|
if (matchingDataItem) {
|
|
42
39
|
var intFile = {
|
|
43
40
|
id: uuid.v4(),
|
|
@@ -129,7 +126,6 @@ export var copyWithToken = function copyWithToken(context) {
|
|
|
129
126
|
fillInResponse(res, resdata);
|
|
130
127
|
return res;
|
|
131
128
|
}
|
|
132
|
-
|
|
133
129
|
return undefined;
|
|
134
130
|
};
|
|
135
131
|
};
|
|
@@ -19,7 +19,6 @@ export var getFile = function getFile(context) {
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
|
|
23
22
|
var availableFiles = [].concat(_toConsumableArray(context().userContext.collection), _toConsumableArray(context().tenantContext.collection));
|
|
24
23
|
var userData = context().userContext.collection.map(requestDataTemplate(context().userContext.collectionName));
|
|
25
24
|
var tenantData = context().tenantContext.collection.map(requestDataTemplate(context().tenantContext.collectionName));
|
|
@@ -27,7 +26,6 @@ export var getFile = function getFile(context) {
|
|
|
27
26
|
var matchingDataItem = data.reduce(function (ret, dataItem) {
|
|
28
27
|
return exactMatch(req, dataItem) ? dataItem : ret;
|
|
29
28
|
}, undefined);
|
|
30
|
-
|
|
31
29
|
if (matchingDataItem) {
|
|
32
30
|
var fileId = (/\/file\/(.*)/.exec(req.url().path || '') || [])[1];
|
|
33
31
|
var resdata = {
|
|
@@ -102,7 +100,6 @@ export var getFile = function getFile(context) {
|
|
|
102
100
|
fillInResponse(res, resdata);
|
|
103
101
|
return res;
|
|
104
102
|
}
|
|
105
|
-
|
|
106
103
|
return undefined;
|
|
107
104
|
};
|
|
108
105
|
};
|
|
@@ -20,14 +20,12 @@ export var getFileImage = function getFileImage(context) {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
|
|
24
23
|
var userData = context().userContext.collection.map(requestDataTemplate(context().userContext.collectionName));
|
|
25
24
|
var tenantData = context().tenantContext.collection.map(requestDataTemplate(context().tenantContext.collectionName));
|
|
26
25
|
var data = [].concat(_toConsumableArray(userData), _toConsumableArray(tenantData));
|
|
27
26
|
var matchingDataItem = data.reduce(function (ret, dataItem) {
|
|
28
27
|
return exactMatch(req, dataItem) ? dataItem : ret;
|
|
29
28
|
}, undefined);
|
|
30
|
-
|
|
31
29
|
if (matchingDataItem) {
|
|
32
30
|
var resdata = {
|
|
33
31
|
status: 200,
|
|
@@ -60,7 +58,6 @@ export var getFileImage = function getFileImage(context) {
|
|
|
60
58
|
fillInResponse(res, resdata);
|
|
61
59
|
return res;
|
|
62
60
|
}
|
|
63
|
-
|
|
64
61
|
return undefined;
|
|
65
62
|
};
|
|
66
63
|
};
|
|
@@ -39,7 +39,6 @@ export var tenantAuth = function tenantAuth(context) {
|
|
|
39
39
|
},
|
|
40
40
|
body: null
|
|
41
41
|
};
|
|
42
|
-
|
|
43
42
|
if (exactMatch(req, data1) || exactMatch(req, data2)) {
|
|
44
43
|
var clientId = '5a9812fc-d029-4a39-8a46-d3cc36eed7ab';
|
|
45
44
|
var token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2NTUzNjI6YjllMGUwYjUtYzYzOS00ZmNiLTk2ZjItMDZmZTZhZTc5NGJlIiwiYWNjZXNzIjp7InVybjpmaWxlc3RvcmU6Y29sbGVjdGlvbjpNZWRpYVNlcnZpY2VzU2FtcGxlIjpbInJlYWQiLCJpbnNlcnQiXSwidXJuOmZpbGVzdG9yZTpjaHVuazoqIjpbImNyZWF0ZSIsInJlYWQiXSwidXJuOmZpbGVzdG9yZTp1cGxvYWQiOlsiY3JlYXRlIl0sInVybjpmaWxlc3RvcmU6dXBsb2FkOioiOlsicmVhZCIsInVwZGF0ZSJdfSwibmJmIjoxNTE5MDkwMDc2LCJleHAiOjE1MTkwOTM2NzYsImlhdCI6MTUxOTA5MDEzNiwiaXNzIjoiNWE5ODEyZmMtZDAyOS00YTM5LThhNDYtZDNjYzM2ZWVkN2FiIn0.7Qr_rZfVLFEBgi5u0xPhjDRCxml75MxDObAhHSnadL4';
|
|
@@ -69,7 +68,6 @@ export var tenantAuth = function tenantAuth(context) {
|
|
|
69
68
|
fillInResponse(res, resdata);
|
|
70
69
|
return res;
|
|
71
70
|
}
|
|
72
|
-
|
|
73
71
|
return undefined;
|
|
74
72
|
};
|
|
75
73
|
};
|
|
@@ -19,10 +19,8 @@ export var userCollectionFetch = function userCollectionFetch(context) {
|
|
|
19
19
|
},
|
|
20
20
|
body: null
|
|
21
21
|
};
|
|
22
|
-
|
|
23
22
|
if (exactMatch(req, data)) {
|
|
24
23
|
var _context$userContext$;
|
|
25
|
-
|
|
26
24
|
var resdata = {
|
|
27
25
|
status: 200,
|
|
28
26
|
reason: '',
|
|
@@ -49,13 +47,10 @@ export var userCollectionFetch = function userCollectionFetch(context) {
|
|
|
49
47
|
}
|
|
50
48
|
})
|
|
51
49
|
};
|
|
52
|
-
|
|
53
50
|
(_context$userContext$ = context().userContext.collection).push.apply(_context$userContext$, _toConsumableArray(userCollection));
|
|
54
|
-
|
|
55
51
|
fillInResponse(res, resdata);
|
|
56
52
|
return res;
|
|
57
53
|
}
|
|
58
|
-
|
|
59
54
|
return undefined;
|
|
60
55
|
};
|
|
61
56
|
};
|
|
@@ -7,7 +7,6 @@ export { dataURItoBlob, fillInResponse } from './utils';
|
|
|
7
7
|
export { copyWithToken, getFile, getFileImage, userCollectionFetch } from './handlers';
|
|
8
8
|
export var MockContext = /*#__PURE__*/_createClass(function MockContext() {
|
|
9
9
|
_classCallCheck(this, MockContext);
|
|
10
|
-
|
|
11
10
|
_defineProperty(this, "userContext", {
|
|
12
11
|
auth: {
|
|
13
12
|
clientId: '',
|
|
@@ -17,7 +16,6 @@ export var MockContext = /*#__PURE__*/_createClass(function MockContext() {
|
|
|
17
16
|
collection: [],
|
|
18
17
|
collectionName: RECENTS_COLLECTION
|
|
19
18
|
});
|
|
20
|
-
|
|
21
19
|
_defineProperty(this, "tenantContext", {
|
|
22
20
|
auth: {
|
|
23
21
|
clientId: '',
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
export var dataURItoBlob = function dataURItoBlob(dataURI) {
|
|
2
2
|
// convert base64 to raw binary data held in a string
|
|
3
|
-
var byteString = atob(dataURI.split(',')[1]);
|
|
3
|
+
var byteString = atob(dataURI.split(',')[1]);
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// separate out the mime component
|
|
6
|
+
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
// write the bytes of the string to an ArrayBuffer
|
|
9
|
+
var ab = new ArrayBuffer(byteString.length);
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
// create a view into the buffer
|
|
12
|
+
var ia = new Uint8Array(ab);
|
|
10
13
|
|
|
14
|
+
// set the bytes of the buffer to the correct values
|
|
11
15
|
for (var i = 0; i < byteString.length; i++) {
|
|
12
16
|
ia[i] = byteString.charCodeAt(i);
|
|
13
|
-
}
|
|
14
|
-
|
|
17
|
+
}
|
|
15
18
|
|
|
19
|
+
// write the ArrayBuffer to a blob, and you're done
|
|
16
20
|
var blob = new Blob([ab], {
|
|
17
21
|
type: mimeString
|
|
18
22
|
});
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
import getJest from './getJest';
|
|
8
5
|
var jest = getJest();
|
|
9
6
|
var getOrientationMock;
|
|
10
|
-
var loadImageMock;
|
|
7
|
+
var loadImageMock;
|
|
11
8
|
|
|
9
|
+
// so that jest doesn't hoist mock of media-ui and replaces actual module on every import of media-test-helpers
|
|
12
10
|
export var loadImageMockSetup = function loadImageMockSetup() {
|
|
13
11
|
jest.doMock('@atlaskit/media-ui', function () {
|
|
14
12
|
return _objectSpread(_objectSpread({}, jest.requireActual('@atlaskit/media-ui')), {}, {
|
|
@@ -3,8 +3,8 @@ import { getHackerNoun, getPastDate, fakeImage, getFakeFileName, getTextFileType
|
|
|
3
3
|
import { mapDataUriToBlob } from '../../utils';
|
|
4
4
|
export function createEmptyCollectionItem(_ref) {
|
|
5
5
|
var id = _ref.id,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
collectionName = _ref.collectionName,
|
|
7
|
+
occurrenceKey = _ref.occurrenceKey;
|
|
8
8
|
return {
|
|
9
9
|
id: id || uuid.v4(),
|
|
10
10
|
insertedAt: getPastDate().valueOf(),
|
|
@@ -18,19 +18,18 @@ export function createEmptyCollectionItem(_ref) {
|
|
|
18
18
|
}
|
|
19
19
|
export function createCollectionItem() {
|
|
20
20
|
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
name = _ref2.name,
|
|
22
|
+
mediaType = _ref2.mediaType,
|
|
23
|
+
mimeType = _ref2.mimeType,
|
|
24
|
+
collectionName = _ref2.collectionName,
|
|
25
|
+
occurrenceKey = _ref2.occurrenceKey,
|
|
26
|
+
_ref2$blob = _ref2.blob,
|
|
27
|
+
blob = _ref2$blob === void 0 ? new Blob(['Hello World'], {
|
|
28
|
+
type: 'text/plain'
|
|
29
|
+
}) : _ref2$blob,
|
|
30
|
+
id = _ref2.id,
|
|
31
|
+
_ref2$processingStatu = _ref2.processingStatus,
|
|
32
|
+
processingStatus = _ref2$processingStatu === void 0 ? 'succeeded' : _ref2$processingStatu;
|
|
34
33
|
var extension = getTextFileType();
|
|
35
34
|
return {
|
|
36
35
|
id: id || uuid.v4(),
|