relay-test-utils-internal 14.1.0 → 16.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/Matchers.js.flow +1 -0
- package/consoleError.js.flow +1 -1
- package/consoleErrorsAndWarnings.js.flow +1 -1
- package/consoleWarning.js.flow +1 -1
- package/describeWithFeatureFlags.js.flow +2 -1
- package/generateTestsFromFixtures.js.flow +1 -0
- package/getOutputForFixture.js.flow +1 -0
- package/index.js +1 -1
- package/index.js.flow +5 -3
- package/lib/Matchers.js +2 -27
- package/lib/consoleError.js +1 -39
- package/lib/consoleErrorsAndWarnings.js +1 -32
- package/lib/consoleWarning.js +1 -39
- package/lib/describeWithFeatureFlags.js +2 -25
- package/lib/generateTestsFromFixtures.js +0 -31
- package/lib/getOutputForFixture.js +0 -13
- package/lib/index.js +20 -48
- package/lib/printAST.js +6 -45
- package/lib/simpleClone.js +1 -20
- package/lib/testschema.graphql +1 -1
- package/lib/trackRetentionForEnvironment.js +1 -26
- package/lib/warnings.js +1 -40
- package/package.json +2 -2
- package/printAST.js.flow +1 -0
- package/relay-test-utils-internal.js +2 -2
- package/relay-test-utils-internal.min.js +2 -2
- package/simpleClone.js.flow +1 -0
- package/trackRetentionForEnvironment.js.flow +4 -2
- package/warnings.js.flow +1 -1
package/Matchers.js.flow
CHANGED
package/consoleError.js.flow
CHANGED
package/consoleWarning.js.flow
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
*
|
7
7
|
* @flow
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
10
11
|
|
11
12
|
/**
|
@@ -46,7 +47,7 @@ declare var describe: {
|
|
46
47
|
};
|
47
48
|
|
48
49
|
function describeWithFeatureFlags(
|
49
|
-
flagSets: Array
|
50
|
+
flagSets: Array<Partial<FeatureFlags>>,
|
50
51
|
description: string,
|
51
52
|
body: () => void,
|
52
53
|
): void {
|
package/index.js
CHANGED
package/index.js.flow
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
*
|
7
7
|
* @flow
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
10
11
|
|
11
12
|
'use strict';
|
@@ -47,11 +48,12 @@ const {createMockEnvironment, unwrapContainer} = require('relay-test-utils');
|
|
47
48
|
function cannotReadPropertyOfUndefined__DEPRECATED(
|
48
49
|
propertyName: string,
|
49
50
|
): string {
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
const matches = process.version.match(/^v(\d+)\./);
|
52
|
+
const majorVersion = matches == null ? null : parseInt(matches[1], 10);
|
53
|
+
if (majorVersion == null || majorVersion < 16) {
|
53
54
|
return `Cannot read property '${propertyName}' of undefined`;
|
54
55
|
}
|
56
|
+
return `Cannot read properties of undefined (reading '${propertyName}')`;
|
55
57
|
}
|
56
58
|
|
57
59
|
/**
|
package/lib/Matchers.js
CHANGED
@@ -1,18 +1,8 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
* @format
|
8
|
-
*/
|
9
1
|
'use strict';
|
10
|
-
/* global expect */
|
11
2
|
|
12
3
|
function toBeDeeplyFrozen(actual) {
|
13
4
|
function check(value) {
|
14
5
|
expect(Object.isFrozen(value)).toBe(true);
|
15
|
-
|
16
6
|
if (Array.isArray(value)) {
|
17
7
|
value.forEach(function (item) {
|
18
8
|
return check(item);
|
@@ -23,28 +13,22 @@ function toBeDeeplyFrozen(actual) {
|
|
23
13
|
}
|
24
14
|
}
|
25
15
|
}
|
26
|
-
|
27
16
|
check(actual);
|
28
17
|
return {
|
29
18
|
pass: true
|
30
19
|
};
|
31
20
|
}
|
32
|
-
|
33
21
|
function toWarn(actual, expected) {
|
34
22
|
var negative = this.isNot;
|
35
|
-
|
36
23
|
function formatItem(item) {
|
37
24
|
return item instanceof RegExp ? item.toString() : JSON.stringify(item);
|
38
25
|
}
|
39
|
-
|
40
26
|
function formatArray(array) {
|
41
27
|
return '[' + array.map(formatItem).join(', ') + ']';
|
42
28
|
}
|
43
|
-
|
44
29
|
function formatExpected(args) {
|
45
30
|
return formatArray([false].concat(args));
|
46
31
|
}
|
47
|
-
|
48
32
|
function formatActual(calls) {
|
49
33
|
if (calls.length) {
|
50
34
|
return calls.map(function (args) {
|
@@ -54,17 +38,13 @@ function toWarn(actual, expected) {
|
|
54
38
|
return '[]';
|
55
39
|
}
|
56
40
|
}
|
57
|
-
|
58
41
|
var warning = require("fbjs/lib/warning");
|
59
|
-
|
60
42
|
if (!warning.mock) {
|
61
43
|
throw new Error("toWarn(): Requires `jest.mock('warning')`.");
|
62
44
|
}
|
63
|
-
|
64
45
|
var callsCount = warning.mock.calls.length;
|
65
46
|
actual();
|
66
|
-
var calls = warning.mock.calls.slice(callsCount);
|
67
|
-
|
47
|
+
var calls = warning.mock.calls.slice(callsCount);
|
68
48
|
if (!expected) {
|
69
49
|
var warned = calls.filter(function (args) {
|
70
50
|
return !args[0];
|
@@ -75,19 +55,15 @@ function toWarn(actual, expected) {
|
|
75
55
|
return "Expected ".concat(negative ? 'not ' : '', "to warn but ") + '`warning` received the following calls: ' + "".concat(formatActual(calls), ".");
|
76
56
|
}
|
77
57
|
};
|
78
|
-
}
|
79
|
-
|
80
|
-
|
58
|
+
}
|
81
59
|
if (!Array.isArray(expected)) {
|
82
60
|
expected = [expected];
|
83
61
|
}
|
84
|
-
|
85
62
|
var call = calls.find(function (args) {
|
86
63
|
return args.length === expected.length + 1 && args.every(function (arg, index) {
|
87
64
|
if (!index) {
|
88
65
|
return !arg;
|
89
66
|
}
|
90
|
-
|
91
67
|
var other = expected[index - 1];
|
92
68
|
return other instanceof RegExp ? other.test(arg) : arg === other;
|
93
69
|
});
|
@@ -99,7 +75,6 @@ function toWarn(actual, expected) {
|
|
99
75
|
}
|
100
76
|
};
|
101
77
|
}
|
102
|
-
|
103
78
|
module.exports = {
|
104
79
|
toBeDeeplyFrozen: toBeDeeplyFrozen,
|
105
80
|
toWarn: toWarn
|
package/lib/consoleError.js
CHANGED
@@ -1,60 +1,22 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
* @emails oncall+relay
|
8
|
-
*
|
9
|
-
* @format
|
10
|
-
*/
|
11
1
|
'use strict';
|
12
|
-
/* global jest */
|
13
2
|
|
14
3
|
var _require = require('./consoleErrorsAndWarnings'),
|
15
|
-
|
16
|
-
|
4
|
+
createConsoleInterceptionSystem = _require.createConsoleInterceptionSystem;
|
17
5
|
var consoleErrorsSystem = createConsoleInterceptionSystem('error', 'expectConsoleError', function (impl) {
|
18
6
|
jest.spyOn(console, 'error').mockImplementation(impl);
|
19
7
|
});
|
20
|
-
/**
|
21
|
-
* Mocks console.error so that errors printed to the console are instead thrown.
|
22
|
-
* Any expected errors need to be explicitly expected with `expectConsoleErrorWillFire(message)`.
|
23
|
-
*
|
24
|
-
* NOTE: This should be called on top of a test file. The test should NOT
|
25
|
-
* use `jest.resetModules()` or manually mock `console`.
|
26
|
-
*/
|
27
|
-
|
28
8
|
function disallowConsoleErrors() {
|
29
9
|
consoleErrorsSystem.disallowMessages();
|
30
10
|
}
|
31
|
-
/**
|
32
|
-
* Expect an error with the given message. If the message isn't fired in the
|
33
|
-
* current test, the test will fail.
|
34
|
-
*/
|
35
|
-
|
36
|
-
|
37
11
|
function expectConsoleErrorWillFire(message, options) {
|
38
12
|
consoleErrorsSystem.expectMessageWillFire(message, options);
|
39
13
|
}
|
40
|
-
/**
|
41
|
-
* Expect the callback `fn` to print an error with the message, and otherwise fail.
|
42
|
-
*/
|
43
|
-
|
44
|
-
|
45
14
|
function expectConsoleError(message, fn) {
|
46
15
|
return consoleErrorsSystem.expectMessage(message, fn);
|
47
16
|
}
|
48
|
-
/**
|
49
|
-
* Expect the callback `fn` to trigger all console errors (in sequence),
|
50
|
-
* and otherwise fail.
|
51
|
-
*/
|
52
|
-
|
53
|
-
|
54
17
|
function expectConsoleErrorsMany(messages, fn) {
|
55
18
|
return consoleErrorsSystem.expectMessageMany(messages, fn);
|
56
19
|
}
|
57
|
-
|
58
20
|
module.exports = {
|
59
21
|
disallowConsoleErrors: disallowConsoleErrors,
|
60
22
|
expectConsoleErrorWillFire: expectConsoleErrorWillFire,
|
@@ -1,22 +1,8 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
* @emails oncall+relay
|
8
|
-
*
|
9
|
-
* @format
|
10
|
-
*/
|
11
1
|
'use strict';
|
12
|
-
/* global afterEach */
|
13
2
|
|
14
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
15
|
-
|
16
4
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
17
|
-
|
18
5
|
var originalConsoleError = console.error;
|
19
|
-
|
20
6
|
function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock) {
|
21
7
|
var installed = false;
|
22
8
|
var expectedMessages = [];
|
@@ -25,7 +11,6 @@ function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock
|
|
25
11
|
var typenameCap = typename.charAt(0).toUpperCase() + typename.slice(1);
|
26
12
|
var typenameCapPlural = typenameCap + 's';
|
27
13
|
var installerName = "disallow".concat(typenameCap, "s");
|
28
|
-
|
29
14
|
function handleMessage(message) {
|
30
15
|
var index = expectedMessages.findIndex(function (expected) {
|
31
16
|
return message.startsWith(expected);
|
@@ -33,7 +18,6 @@ function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock
|
|
33
18
|
var optionalIndex = optionalMessages.findIndex(function (expected) {
|
34
19
|
return message.startsWith(expected);
|
35
20
|
});
|
36
|
-
|
37
21
|
if (contextualExpectedMessage.length > 0 && message.startsWith(contextualExpectedMessage[0])) {
|
38
22
|
contextualExpectedMessage.shift();
|
39
23
|
} else if (index >= 0) {
|
@@ -41,23 +25,19 @@ function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock
|
|
41
25
|
} else if (optionalIndex >= 0) {
|
42
26
|
optionalMessages.splice(optionalIndex, 1);
|
43
27
|
} else {
|
44
|
-
// log to console in case the error gets swallowed somewhere
|
45
28
|
originalConsoleError("Unexpected ".concat(typenameCap, ": ") + message);
|
46
29
|
throw new Error("".concat(typenameCap, ": ") + message);
|
47
30
|
}
|
48
31
|
}
|
49
|
-
|
50
32
|
function disallowMessages() {
|
51
33
|
if (installed) {
|
52
34
|
throw new Error("".concat(installerName, " should be called only once."));
|
53
35
|
}
|
54
|
-
|
55
36
|
installed = true;
|
56
37
|
setUpMock(handleMessage);
|
57
38
|
afterEach(function () {
|
58
39
|
optionalMessages.length = 0;
|
59
40
|
contextualExpectedMessage.length = 0;
|
60
|
-
|
61
41
|
if (expectedMessages.length > 0) {
|
62
42
|
var error = new Error("Some ".concat(expectedMessages.length, " expected ").concat(typename, "s where not triggered:\n\n") + Array.from(expectedMessages, function (message) {
|
63
43
|
return " * ".concat(message);
|
@@ -67,42 +47,32 @@ function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock
|
|
67
47
|
}
|
68
48
|
});
|
69
49
|
}
|
70
|
-
|
71
50
|
function expectMessageWillFire(message, options) {
|
72
51
|
if (!installed) {
|
73
52
|
throw new Error("".concat(installerName, " needs to be called before expect").concat(typenameCapPlural, "WillFire"));
|
74
53
|
}
|
75
|
-
|
76
|
-
var optional = (options === null || options === void 0 ? void 0 : options.optional) === true; // avoid "sketchy null check"
|
77
|
-
|
54
|
+
var optional = (options === null || options === void 0 ? void 0 : options.optional) === true;
|
78
55
|
for (var i = 0; i < ((_options$count = options === null || options === void 0 ? void 0 : options.count) !== null && _options$count !== void 0 ? _options$count : 1); i++) {
|
79
56
|
var _options$count;
|
80
|
-
|
81
57
|
(optional ? optionalMessages : expectedMessages).push(message);
|
82
58
|
}
|
83
59
|
}
|
84
|
-
|
85
60
|
function expectMessage(message, fn) {
|
86
61
|
return expectMessageMany([message], fn);
|
87
62
|
}
|
88
|
-
|
89
63
|
function expectMessageMany(messages, fn) {
|
90
64
|
if (contextualExpectedMessage.length > 0) {
|
91
65
|
throw new Error("Cannot nest ".concat(expectFunctionName, "() calls."));
|
92
66
|
}
|
93
|
-
|
94
67
|
contextualExpectedMessage.push.apply(contextualExpectedMessage, (0, _toConsumableArray2["default"])(messages));
|
95
68
|
var result = fn();
|
96
|
-
|
97
69
|
if (contextualExpectedMessage.length > 0) {
|
98
70
|
var notFired = contextualExpectedMessage.toString();
|
99
71
|
contextualExpectedMessage.length = 0;
|
100
72
|
throw new Error("Expected ".concat(typename, " in callback: ").concat(notFired));
|
101
73
|
}
|
102
|
-
|
103
74
|
return result;
|
104
75
|
}
|
105
|
-
|
106
76
|
return {
|
107
77
|
disallowMessages: disallowMessages,
|
108
78
|
expectMessageWillFire: expectMessageWillFire,
|
@@ -110,7 +80,6 @@ function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock
|
|
110
80
|
expectMessageMany: expectMessageMany
|
111
81
|
};
|
112
82
|
}
|
113
|
-
|
114
83
|
module.exports = {
|
115
84
|
createConsoleInterceptionSystem: createConsoleInterceptionSystem
|
116
85
|
};
|
package/lib/consoleWarning.js
CHANGED
@@ -1,60 +1,22 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
* @emails oncall+relay
|
8
|
-
*
|
9
|
-
* @format
|
10
|
-
*/
|
11
1
|
'use strict';
|
12
|
-
/* global jest */
|
13
2
|
|
14
3
|
var _require = require('./consoleErrorsAndWarnings'),
|
15
|
-
|
16
|
-
|
4
|
+
createConsoleInterceptionSystem = _require.createConsoleInterceptionSystem;
|
17
5
|
var consoleWarningsSystem = createConsoleInterceptionSystem('warning', 'expectConsoleWarning', function (impl) {
|
18
6
|
jest.spyOn(console, 'warn').mockImplementation(impl);
|
19
7
|
});
|
20
|
-
/**
|
21
|
-
* Mocks console.warn so that warnings printed to the console are instead thrown.
|
22
|
-
* Any expected warnings need to be explicitly expected with `expectConsoleWarningWillFire(message)`.
|
23
|
-
*
|
24
|
-
* NOTE: This should be called on top of a test file. The test should NOT
|
25
|
-
* use `jest.resetModules()` or manually mock `console`.
|
26
|
-
*/
|
27
|
-
|
28
8
|
function disallowConsoleWarnings() {
|
29
9
|
consoleWarningsSystem.disallowMessages();
|
30
10
|
}
|
31
|
-
/**
|
32
|
-
* Expect a warning with the given message. If the message isn't fired in the
|
33
|
-
* current test, the test will fail.
|
34
|
-
*/
|
35
|
-
|
36
|
-
|
37
11
|
function expectConsoleWarningWillFire(message, options) {
|
38
12
|
consoleWarningsSystem.expectMessageWillFire(message, options);
|
39
13
|
}
|
40
|
-
/**
|
41
|
-
* Expect the callback `fn` to print a warning with the message, and otherwise fail.
|
42
|
-
*/
|
43
|
-
|
44
|
-
|
45
14
|
function expectConsoleWarning(message, fn) {
|
46
15
|
return consoleWarningsSystem.expectMessage(message, fn);
|
47
16
|
}
|
48
|
-
/**
|
49
|
-
* Expect the callback `fn` to trigger all console warnings (in sequence),
|
50
|
-
* and otherwise fail.
|
51
|
-
*/
|
52
|
-
|
53
|
-
|
54
17
|
function expectConsoleWarningsMany(messages, fn) {
|
55
18
|
return consoleWarningsSystem.expectMessageMany(messages, fn);
|
56
19
|
}
|
57
|
-
|
58
20
|
module.exports = {
|
59
21
|
disallowConsoleWarnings: disallowConsoleWarnings,
|
60
22
|
expectConsoleWarningWillFire: expectConsoleWarningWillFire,
|
@@ -1,45 +1,22 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
*/
|
10
|
-
|
11
|
-
/**
|
12
|
-
* Run a test suite under multiple sets of feature flags.
|
13
|
-
* Beware that calling jest.resetModules() within the suite may break this.
|
14
|
-
*/
|
15
1
|
'use strict';
|
16
2
|
|
17
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
18
|
-
|
19
4
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
20
|
-
|
21
|
-
// This function is for running within a test environment, so we use globals
|
22
|
-
// available within tests -- taken from:
|
23
|
-
// i code/www/[5ee5e1d71a05e9f58ded3c1c22b810666383164f]/flow/shared/libdefs/jest.js
|
24
5
|
function describeWithFeatureFlags(flagSets, description, body) {
|
25
6
|
describe.each(flagSets)("".concat(description, " - Feature flags: %o"), function (flags) {
|
26
7
|
var originalFlags;
|
27
8
|
beforeEach(function () {
|
28
9
|
var _require = require('relay-runtime'),
|
29
|
-
|
30
|
-
|
10
|
+
RelayFeatureFlags = _require.RelayFeatureFlags;
|
31
11
|
originalFlags = (0, _objectSpread2["default"])({}, RelayFeatureFlags);
|
32
12
|
Object.assign(RelayFeatureFlags, flags);
|
33
13
|
});
|
34
14
|
afterEach(function () {
|
35
15
|
var _require2 = require('relay-runtime'),
|
36
|
-
|
37
|
-
|
38
|
-
|
16
|
+
RelayFeatureFlags = _require2.RelayFeatureFlags;
|
39
17
|
Object.assign(RelayFeatureFlags, originalFlags);
|
40
18
|
});
|
41
19
|
body();
|
42
20
|
});
|
43
21
|
}
|
44
|
-
|
45
22
|
module.exports = describeWithFeatureFlags;
|
@@ -1,30 +1,10 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
* @format
|
8
|
-
*/
|
9
1
|
'use strict';
|
10
2
|
|
11
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
12
|
-
|
13
4
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
14
|
-
|
15
5
|
var getOutputForFixture = require('./getOutputForFixture');
|
16
|
-
|
17
6
|
var fs = require('fs');
|
18
|
-
|
19
7
|
var path = require('path');
|
20
|
-
/* global expect,test */
|
21
|
-
|
22
|
-
/**
|
23
|
-
* Extend Jest with a custom snapshot serializer to provide additional context
|
24
|
-
* and reduce the amount of escaping that occurs.
|
25
|
-
*/
|
26
|
-
|
27
|
-
|
28
8
|
var FIXTURE_TAG = Symbol["for"]('FIXTURE_TAG');
|
29
9
|
expect.addSnapshotSerializer({
|
30
10
|
print: function print(value) {
|
@@ -36,13 +16,6 @@ expect.addSnapshotSerializer({
|
|
36
16
|
return value && value[FIXTURE_TAG] === true;
|
37
17
|
}
|
38
18
|
});
|
39
|
-
/**
|
40
|
-
* Generates a set of jest snapshot tests that compare the output of the
|
41
|
-
* provided `operation` to each of the matching files in the `fixturesPath`.
|
42
|
-
* The fixture should have '# expected-to-throw' on its first line
|
43
|
-
* if it is expected to fail
|
44
|
-
*/
|
45
|
-
|
46
19
|
function generateTestsFromFixtures(fixturesPath, operation) {
|
47
20
|
var fixtures = fs.readdirSync(fixturesPath);
|
48
21
|
test("has fixtures in ".concat(fixturesPath), function () {
|
@@ -51,23 +24,19 @@ function generateTestsFromFixtures(fixturesPath, operation) {
|
|
51
24
|
var onlyFixtures = fixtures.filter(function (name) {
|
52
25
|
return name.startsWith('only.');
|
53
26
|
});
|
54
|
-
|
55
27
|
if (onlyFixtures.length) {
|
56
28
|
test.skip.each(fixtures.filter(function (name) {
|
57
29
|
return !name.startsWith('only.');
|
58
30
|
}))('matches expected output: %s', function () {});
|
59
31
|
fixtures = onlyFixtures;
|
60
32
|
}
|
61
|
-
|
62
33
|
test.each(fixtures)('matches expected output: %s', function (file) {
|
63
34
|
var _expect;
|
64
|
-
|
65
35
|
var input = fs.readFileSync(path.join(fixturesPath, file), 'utf8');
|
66
36
|
var output = getOutputForFixture(input, operation, file);
|
67
37
|
expect((_expect = {}, (0, _defineProperty2["default"])(_expect, FIXTURE_TAG, true), (0, _defineProperty2["default"])(_expect, "input", input), (0, _defineProperty2["default"])(_expect, "output", output), _expect)).toMatchSnapshot();
|
68
38
|
});
|
69
39
|
}
|
70
|
-
|
71
40
|
module.exports = {
|
72
41
|
generateTestsFromFixtures: generateTestsFromFixtures,
|
73
42
|
FIXTURE_TAG: FIXTURE_TAG
|
@@ -1,30 +1,17 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
*/
|
10
1
|
'use strict';
|
11
2
|
|
12
3
|
function getOutputForFixture(input, operation, file) {
|
13
4
|
var shouldThrow = /^# *expected-to-throw/.test(input) || /\.error\.\w+$/.test(file);
|
14
|
-
|
15
5
|
if (shouldThrow) {
|
16
6
|
var result;
|
17
|
-
|
18
7
|
try {
|
19
8
|
result = operation(input);
|
20
9
|
} catch (e) {
|
21
10
|
return "THROWN EXCEPTION:\n\n".concat(e.toString());
|
22
11
|
}
|
23
|
-
|
24
12
|
throw new Error("Expected test file '".concat(file, "' to throw, but it passed:\n").concat(result));
|
25
13
|
} else {
|
26
14
|
return operation(input);
|
27
15
|
}
|
28
16
|
}
|
29
|
-
|
30
17
|
module.exports = getOutputForFixture;
|
package/lib/index.js
CHANGED
@@ -1,67 +1,39 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
*/
|
10
1
|
'use strict';
|
11
2
|
|
12
3
|
var _require = require('./consoleError'),
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
disallowConsoleErrors = _require.disallowConsoleErrors,
|
5
|
+
expectConsoleError = _require.expectConsoleError,
|
6
|
+
expectConsoleErrorsMany = _require.expectConsoleErrorsMany,
|
7
|
+
expectConsoleErrorWillFire = _require.expectConsoleErrorWillFire;
|
18
8
|
var _require2 = require('./consoleWarning'),
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
9
|
+
disallowConsoleWarnings = _require2.disallowConsoleWarnings,
|
10
|
+
expectConsoleWarning = _require2.expectConsoleWarning,
|
11
|
+
expectConsoleWarningsMany = _require2.expectConsoleWarningsMany,
|
12
|
+
expectConsoleWarningWillFire = _require2.expectConsoleWarningWillFire;
|
24
13
|
var describeWithFeatureFlags = require('./describeWithFeatureFlags');
|
25
|
-
|
26
14
|
var _require3 = require('./generateTestsFromFixtures'),
|
27
|
-
|
28
|
-
|
29
|
-
|
15
|
+
FIXTURE_TAG = _require3.FIXTURE_TAG,
|
16
|
+
generateTestsFromFixtures = _require3.generateTestsFromFixtures;
|
30
17
|
var Matchers = require('./Matchers');
|
31
|
-
|
32
18
|
var printAST = require('./printAST');
|
33
|
-
|
34
19
|
var simpleClone = require('./simpleClone');
|
35
|
-
|
36
20
|
var trackRetentionForEnvironment = require('./trackRetentionForEnvironment');
|
37
|
-
|
38
21
|
var _require4 = require('./warnings'),
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
22
|
+
disallowWarnings = _require4.disallowWarnings,
|
23
|
+
expectToWarn = _require4.expectToWarn,
|
24
|
+
expectToWarnMany = _require4.expectToWarnMany,
|
25
|
+
expectWarningWillFire = _require4.expectWarningWillFire;
|
44
26
|
var _require5 = require('relay-test-utils'),
|
45
|
-
|
46
|
-
|
47
|
-
// the content of the TypeError has changed, and now some of our tests
|
48
|
-
// stated to fail.
|
49
|
-
// This is a temporary work-around to make test pass, but we need to
|
50
|
-
// figure out a cleaner way of testing this.
|
51
|
-
|
52
|
-
|
27
|
+
createMockEnvironment = _require5.createMockEnvironment,
|
28
|
+
unwrapContainer = _require5.unwrapContainer;
|
53
29
|
function cannotReadPropertyOfUndefined__DEPRECATED(propertyName) {
|
54
|
-
|
55
|
-
|
56
|
-
|
30
|
+
var matches = process.version.match(/^v(\d+)\./);
|
31
|
+
var majorVersion = matches == null ? null : parseInt(matches[1], 10);
|
32
|
+
if (majorVersion == null || majorVersion < 16) {
|
57
33
|
return "Cannot read property '".concat(propertyName, "' of undefined");
|
58
34
|
}
|
35
|
+
return "Cannot read properties of undefined (reading '".concat(propertyName, "')");
|
59
36
|
}
|
60
|
-
/**
|
61
|
-
* The public interface to Relay Test Utils.
|
62
|
-
*/
|
63
|
-
|
64
|
-
|
65
37
|
module.exports = {
|
66
38
|
cannotReadPropertyOfUndefined__DEPRECATED: cannotReadPropertyOfUndefined__DEPRECATED,
|
67
39
|
createMockEnvironment: createMockEnvironment,
|
package/lib/printAST.js
CHANGED
@@ -1,37 +1,14 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
*/
|
10
1
|
'use strict';
|
11
|
-
/**
|
12
|
-
* Prints a JSON AST similar to JSON.stringify(ast, null, 2) with some changes:
|
13
|
-
* - Adds trailing commas to simplify diffs.
|
14
|
-
* - Prints `undefined` as `undefined`.
|
15
|
-
* - Errors on unhandled types instead of skipping keys.
|
16
|
-
* - If an object has a key `kind` with a string value, prints the object as:
|
17
|
-
* SomeKind {
|
18
|
-
* prop: value,
|
19
|
-
* }
|
20
|
-
*/
|
21
2
|
|
22
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
23
|
-
|
24
4
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
25
|
-
|
26
5
|
function printAST(ast) {
|
27
6
|
return printASTImpl(ast, '');
|
28
7
|
}
|
29
|
-
|
30
8
|
function printASTImpl(ast, indent) {
|
31
9
|
switch (typeof ast) {
|
32
10
|
case 'undefined':
|
33
11
|
return 'undefined';
|
34
|
-
|
35
12
|
case 'object':
|
36
13
|
{
|
37
14
|
if (ast === null) {
|
@@ -40,13 +17,10 @@ function printASTImpl(ast, indent) {
|
|
40
17
|
if (ast.length === 0) {
|
41
18
|
return '[]';
|
42
19
|
}
|
43
|
-
|
44
20
|
var result = '[\n';
|
45
21
|
var itemIndent = indent + ' ';
|
46
|
-
|
47
22
|
var _iterator = (0, _createForOfIteratorHelper2["default"])(ast),
|
48
|
-
|
49
|
-
|
23
|
+
_step;
|
50
24
|
try {
|
51
25
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
52
26
|
var item = _step.value;
|
@@ -57,56 +31,43 @@ function printASTImpl(ast, indent) {
|
|
57
31
|
} finally {
|
58
32
|
_iterator.f();
|
59
33
|
}
|
60
|
-
|
61
34
|
result += indent + ']';
|
62
35
|
return result;
|
63
36
|
} else if (typeof ast.kind === 'string') {
|
64
37
|
var _result = "".concat(ast.kind, " {\n");
|
65
|
-
|
66
38
|
var keyIndent = indent + ' ';
|
67
|
-
|
68
39
|
for (var _i = 0, _Object$entries = Object.entries(ast); _i < _Object$entries.length; _i++) {
|
69
40
|
var _Object$entries$_i = _Object$entries[_i],
|
70
|
-
|
71
|
-
|
72
|
-
|
41
|
+
key = _Object$entries$_i[0],
|
42
|
+
value = _Object$entries$_i[1];
|
73
43
|
if (key === 'kind') {
|
74
44
|
continue;
|
75
45
|
}
|
76
|
-
|
77
46
|
_result += "".concat(keyIndent).concat(key, ": ").concat(printASTImpl(value, keyIndent), ",\n");
|
78
47
|
}
|
79
|
-
|
80
48
|
_result += indent + '}';
|
81
49
|
return _result;
|
82
50
|
} else if (typeof ast.toJSON === 'function') {
|
83
|
-
return printASTImpl(
|
84
|
-
ast.toJSON(), indent);
|
51
|
+
return printASTImpl(ast.toJSON(), indent);
|
85
52
|
} else {
|
86
53
|
var _result2 = '{\n';
|
87
|
-
|
88
54
|
var _keyIndent = indent + ' ';
|
89
|
-
|
90
55
|
for (var _i2 = 0, _Object$entries2 = Object.entries(ast); _i2 < _Object$entries2.length; _i2++) {
|
91
56
|
var _Object$entries2$_i = _Object$entries2[_i2],
|
92
|
-
|
93
|
-
|
57
|
+
_key = _Object$entries2$_i[0],
|
58
|
+
_value = _Object$entries2$_i[1];
|
94
59
|
_result2 += "".concat(_keyIndent).concat(JSON.stringify(_key), ": ").concat(printASTImpl(_value, _keyIndent), ",\n");
|
95
60
|
}
|
96
|
-
|
97
61
|
_result2 += indent + '}';
|
98
62
|
return _result2;
|
99
63
|
}
|
100
64
|
}
|
101
|
-
|
102
65
|
case 'string':
|
103
66
|
case 'number':
|
104
67
|
case 'boolean':
|
105
68
|
return JSON.stringify(ast, null, 2).replace('\n', '\n' + indent);
|
106
|
-
|
107
69
|
default:
|
108
70
|
throw new Error("printAST doesn't handle values where " + "typeof value === '".concat(typeof ast, "'."));
|
109
71
|
}
|
110
72
|
}
|
111
|
-
|
112
73
|
module.exports = printAST;
|
package/lib/simpleClone.js
CHANGED
@@ -1,35 +1,16 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
*/
|
10
1
|
'use strict';
|
11
|
-
/**
|
12
|
-
* A helper to create a deep clone of a value, plain Object, or array of such.
|
13
|
-
*
|
14
|
-
* Does not support RegExp, Date, other classes, or self-referential values.
|
15
|
-
*/
|
16
2
|
|
17
3
|
function simpleClone(value) {
|
18
4
|
if (Array.isArray(value)) {
|
19
|
-
// $FlowFixMe[incompatible-return]
|
20
5
|
return value.map(simpleClone);
|
21
6
|
} else if (value != null && typeof value === 'object') {
|
22
7
|
var result = {};
|
23
|
-
|
24
8
|
for (var key in value) {
|
25
9
|
result[key] = simpleClone(value[key]);
|
26
|
-
}
|
27
|
-
|
28
|
-
|
10
|
+
}
|
29
11
|
return result;
|
30
12
|
} else {
|
31
13
|
return value;
|
32
14
|
}
|
33
15
|
}
|
34
|
-
|
35
16
|
module.exports = simpleClone;
|
package/lib/testschema.graphql
CHANGED
@@ -1,38 +1,18 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
*/
|
10
1
|
'use strict';
|
11
|
-
/* global jest */
|
12
2
|
|
13
|
-
/**
|
14
|
-
* Takes an environment and augments it with a mock implementation of `retain`
|
15
|
-
* that tracks what operations are currently retained. Also returns the Jest mock
|
16
|
-
* `release` function for backwards-compatibility with existing tests, but you
|
17
|
-
* should use `isOperationRetained` for new tests as it is much less error-prone.
|
18
|
-
*/
|
19
3
|
function trackRetentionForEnvironment(environment) {
|
20
4
|
var retainCountsByOperation = new Map();
|
21
5
|
var release = jest.fn(function (id) {
|
22
6
|
var _retainCountsByOperat;
|
23
|
-
|
24
7
|
var existing = (_retainCountsByOperat = retainCountsByOperation.get(id)) !== null && _retainCountsByOperat !== void 0 ? _retainCountsByOperat : NaN;
|
25
|
-
|
26
8
|
if (existing === 1) {
|
27
9
|
retainCountsByOperation["delete"](id);
|
28
10
|
} else {
|
29
11
|
retainCountsByOperation.set(id, existing - 1);
|
30
12
|
}
|
31
|
-
});
|
32
|
-
|
13
|
+
});
|
33
14
|
environment.retain = jest.fn(function (operation) {
|
34
15
|
var _retainCountsByOperat2;
|
35
|
-
|
36
16
|
var id = operation.request.identifier;
|
37
17
|
var existing = (_retainCountsByOperat2 = retainCountsByOperation.get(id)) !== null && _retainCountsByOperat2 !== void 0 ? _retainCountsByOperat2 : 0;
|
38
18
|
retainCountsByOperation.set(id, existing + 1);
|
@@ -42,23 +22,18 @@ function trackRetentionForEnvironment(environment) {
|
|
42
22
|
if (!released) {
|
43
23
|
release(id);
|
44
24
|
}
|
45
|
-
|
46
25
|
released = true;
|
47
26
|
}
|
48
27
|
};
|
49
28
|
});
|
50
|
-
|
51
29
|
function isOperationRetained(operation) {
|
52
30
|
var _retainCountsByOperat3;
|
53
|
-
|
54
31
|
var id = operation.request.identifier;
|
55
32
|
return ((_retainCountsByOperat3 = retainCountsByOperation.get(id)) !== null && _retainCountsByOperat3 !== void 0 ? _retainCountsByOperat3 : 0) > 0;
|
56
33
|
}
|
57
|
-
|
58
34
|
return {
|
59
35
|
release_DEPRECATED: release,
|
60
36
|
isOperationRetained: isOperationRetained
|
61
37
|
};
|
62
38
|
}
|
63
|
-
|
64
39
|
module.exports = trackRetentionForEnvironment;
|
package/lib/warnings.js
CHANGED
@@ -1,26 +1,13 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
* @emails oncall+relay
|
8
|
-
*
|
9
|
-
* @format
|
10
|
-
*/
|
11
1
|
'use strict';
|
12
|
-
/* global jest */
|
13
2
|
|
14
3
|
var _require = require('./consoleErrorsAndWarnings'),
|
15
|
-
|
16
|
-
|
4
|
+
createConsoleInterceptionSystem = _require.createConsoleInterceptionSystem;
|
17
5
|
var warningsSystem = createConsoleInterceptionSystem('warning', 'expectToWarn', function (impl) {
|
18
6
|
jest.mock("fbjs/lib/warning", function () {
|
19
7
|
return jest.fn(function (condition, format) {
|
20
8
|
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
21
9
|
args[_key - 2] = arguments[_key];
|
22
10
|
}
|
23
|
-
|
24
11
|
if (!condition) {
|
25
12
|
var argIndex = 0;
|
26
13
|
var message = format.replace(/%s/g, function () {
|
@@ -31,44 +18,18 @@ var warningsSystem = createConsoleInterceptionSystem('warning', 'expectToWarn',
|
|
31
18
|
});
|
32
19
|
});
|
33
20
|
});
|
34
|
-
/**
|
35
|
-
* Mocks the `warning` module to turn warnings into errors. Any expected
|
36
|
-
* warnings need to be explicitly expected with `expectWarningWillFire(message)`.
|
37
|
-
*
|
38
|
-
* NOTE: This should be called on top of a test file. The test should NOT
|
39
|
-
* use `jest.resetModules()` or manually mock `warning`.
|
40
|
-
*/
|
41
|
-
|
42
21
|
function disallowWarnings() {
|
43
22
|
warningsSystem.disallowMessages();
|
44
23
|
}
|
45
|
-
/**
|
46
|
-
* Expect a warning with the given message. If the message isn't fired in the
|
47
|
-
* current test, the test will fail.
|
48
|
-
*/
|
49
|
-
|
50
|
-
|
51
24
|
function expectWarningWillFire(message, options) {
|
52
25
|
warningsSystem.expectMessageWillFire(message, options);
|
53
26
|
}
|
54
|
-
/**
|
55
|
-
* Expect the callback `fn` to trigger the warning message and otherwise fail.
|
56
|
-
*/
|
57
|
-
|
58
|
-
|
59
27
|
function expectToWarn(message, fn) {
|
60
28
|
return warningsSystem.expectMessage(message, fn);
|
61
29
|
}
|
62
|
-
/**
|
63
|
-
* Expect the callback `fn` to trigger all warning messages (in sequence)
|
64
|
-
* or otherwise fail.
|
65
|
-
*/
|
66
|
-
|
67
|
-
|
68
30
|
function expectToWarnMany(messages, fn) {
|
69
31
|
return warningsSystem.expectMessageMany(messages, fn);
|
70
32
|
}
|
71
|
-
|
72
33
|
module.exports = {
|
73
34
|
disallowWarnings: disallowWarnings,
|
74
35
|
expectWarningWillFire: expectWarningWillFire,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "relay-test-utils-internal",
|
3
3
|
"description": "Internal utilities for testing Relay.",
|
4
|
-
"version": "
|
4
|
+
"version": "16.0.0",
|
5
5
|
"keywords": [
|
6
6
|
"graphql",
|
7
7
|
"relay"
|
@@ -17,7 +17,7 @@
|
|
17
17
|
"dependencies": {
|
18
18
|
"@babel/runtime": "^7.0.0",
|
19
19
|
"fbjs": "^3.0.2",
|
20
|
-
"relay-runtime": "
|
20
|
+
"relay-runtime": "16.0.0"
|
21
21
|
},
|
22
22
|
"directories": {
|
23
23
|
"": "./"
|
package/printAST.js.flow
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
/**
|
2
|
-
* Relay
|
2
|
+
* Relay v16.0.0
|
3
3
|
*/
|
4
|
-
module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=3)}([function(e,n){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(5)),o=console.error;e.exports={createConsoleInterceptionSystem:function(e,n,t){var i=!1,c=[],a=[],s=[],u=e.charAt(0).toUpperCase()+e.slice(1),l=u+"s",f="disallow".concat(u,"s");function p(e){var n=c.findIndex((function(n){return e.startsWith(n)})),t=a.findIndex((function(n){return e.startsWith(n)}));if(s.length>0&&e.startsWith(s[0]))s.shift();else if(n>=0)c.splice(n,1);else{if(!(t>=0))throw o("Unexpected ".concat(u,": ")+e),new Error("".concat(u,": ")+e);a.splice(t,1)}}function d(t,o){if(s.length>0)throw new Error("Cannot nest ".concat(n,"() calls."));s.push.apply(s,(0,r.default)(t));var i=o();if(s.length>0){var c=s.toString();throw s.length=0,new Error("Expected ".concat(e," in callback: ").concat(c))}return i}return{disallowMessages:function(){if(i)throw new Error("".concat(f," should be called only once."));i=!0,t(p),afterEach((function(){if(a.length=0,s.length=0,c.length>0){var n=new Error("Some ".concat(c.length," expected ").concat(e,"s where not triggered:\n\n")+Array.from(c,(function(e){return" * ".concat(e)})).join("\n")+"\n");throw c.length=0,n}}))},expectMessageWillFire:function(e,n){if(!i)throw new Error("".concat(f," needs to be called before expect").concat(l,"WillFire"));for(var t=!0===(null==n?void 0:n.optional),r=0;r<(null!==(o=null==n?void 0:n.count)&&void 0!==o?o:1);r++){var o;(t?a:c).push(e)}},expectMessage:function(e,n){return d([e],n)},expectMessageMany:d}}}},function(e,n){e.exports=require("relay-runtime")},function(e,n,t){"use strict";var r=t(4),o=r.disallowConsoleErrors,i=r.expectConsoleError,c=r.expectConsoleErrorsMany,a=r.expectConsoleErrorWillFire,s=t(6),u=s.disallowConsoleWarnings,l=s.expectConsoleWarning,f=s.expectConsoleWarningsMany,p=s.expectConsoleWarningWillFire,d=t(7),g=t(9),x=g.FIXTURE_TAG,h=g.generateTestsFromFixtures,y=t(14),v=t(16),w=t(18),b=t(19),m=t(20),W=m.disallowWarnings,E=m.expectToWarn,C=m.expectToWarnMany,M=m.expectWarningWillFire,F=t(21),j=F.createMockEnvironment,S=F.unwrapContainer;e.exports={cannotReadPropertyOfUndefined__DEPRECATED:function(e){return process.version.match(/^v16\.(.+)$/)?"Cannot read properties of undefined (reading '".concat(e,"')"):"Cannot read property '".concat(e,"' of undefined")},createMockEnvironment:j,describeWithFeatureFlags:d,disallowConsoleErrors:o,disallowConsoleWarnings:u,disallowWarnings:W,expectConsoleError:i,expectConsoleErrorsMany:c,expectConsoleErrorWillFire:a,expectConsoleWarningWillFire:p,expectConsoleWarning:l,expectConsoleWarningsMany:f,expectToWarn:E,expectToWarnMany:C,expectWarningWillFire:M,FIXTURE_TAG:x,generateTestsFromFixtures:h,matchers:y,printAST:v,simpleClone:w,trackRetentionForEnvironment:b,unwrapContainer:S}},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("error","expectConsoleError",(function(e){jest.spyOn(console,"error").mockImplementation(e)}));e.exports={disallowConsoleErrors:function(){r.disallowMessages()},expectConsoleErrorWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectConsoleError:function(e,n){return r.expectMessage(e,n)},expectConsoleErrorsMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("warning","expectConsoleWarning",(function(e){jest.spyOn(console,"warn").mockImplementation(e)}));e.exports={disallowConsoleWarnings:function(){r.disallowMessages()},expectConsoleWarningWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectConsoleWarning:function(e,n){return r.expectMessage(e,n)},expectConsoleWarningsMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n,t){"use strict";var r=(0,t(0).default)(t(8));e.exports=function(e,n,o){describe.each(e)("".concat(n," - Feature flags: %o"),(function(e){var n;beforeEach((function(){var o=t(2).RelayFeatureFlags;n=(0,r.default)({},o),Object.assign(o,e)})),afterEach((function(){var e=t(2).RelayFeatureFlags;Object.assign(e,n)})),o()}))}},function(e,n){e.exports=require("@babel/runtime/helpers/objectSpread2")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(10)),o=t(11),i=t(12),c=t(13),a=Symbol.for("FIXTURE_TAG");expect.addSnapshotSerializer({print:function(e){return Object.keys(e).map((function(n){return"~~~~~~~~~~ ".concat(n.toUpperCase()," ~~~~~~~~~~\n").concat(e[n])})).join("\n")},test:function(e){return e&&!0===e[a]}}),e.exports={generateTestsFromFixtures:function(e,n){var t=i.readdirSync(e);test("has fixtures in ".concat(e),(function(){expect(t.length>0).toBe(!0)}));var s=t.filter((function(e){return e.startsWith("only.")}));s.length&&(test.skip.each(t.filter((function(e){return!e.startsWith("only.")})))("matches expected output: %s",(function(){})),t=s),test.each(t)("matches expected output: %s",(function(t){var s,u=i.readFileSync(c.join(e,t),"utf8"),l=o(u,n,t);expect((s={},(0,r.default)(s,a,!0),(0,r.default)(s,"input",u),(0,r.default)(s,"output",l),s)).toMatchSnapshot()}))},FIXTURE_TAG:a}},function(e,n){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,n,t){"use strict";e.exports=function(e,n,t){if(/^# *expected-to-throw/.test(e)||/\.error\.\w+$/.test(t)){var r;try{r=n(e)}catch(e){return"THROWN EXCEPTION:\n\n".concat(e.toString())}throw new Error("Expected test file '".concat(t,"' to throw, but it passed:\n").concat(r))}return n(e)}},function(e,n){e.exports=require("fs")},function(e,n){e.exports=require("path")},function(e,n,t){"use strict";e.exports={toBeDeeplyFrozen:function(e){return function e(n){if(expect(Object.isFrozen(n)).toBe(!0),Array.isArray(n))n.forEach((function(n){return e(n)}));else if("object"==typeof n&&null!==n)for(var t in n)e(n[t])}(e),{pass:!0}},toWarn:function(e,n){var r=this.isNot;function o(e){return e instanceof RegExp?e.toString():JSON.stringify(e)}function i(e){return"["+e.map(o).join(", ")+"]"}function c(e){return e.length?e.map((function(e){return i([!!e[0]].concat(e.slice(1)))})).join(", "):"[]"}var a=t(15);if(!a.mock)throw new Error("toWarn(): Requires `jest.mock('warning')`.");var s=a.mock.calls.length;e();var u=a.mock.calls.slice(s);return n?(Array.isArray(n)||(n=[n]),{pass:!!u.find((function(e){return e.length===n.length+1&&e.every((function(e,t){if(!t)return!e;var r=n[t-1];return r instanceof RegExp?r.test(e):e===r}))})),message:function(){return"Expected ".concat(r?"not ":"","to warn: ")+"".concat(i([!1].concat(n))," but ")+"`warning` received the following calls: "+"".concat(c(u),".")}}):{pass:!!u.filter((function(e){return!e[0]})).length,message:function(){return"Expected ".concat(r?"not ":"","to warn but ")+"`warning` received the following calls: "+"".concat(c(u),".")}}}}},function(e,n){e.exports=require("fbjs/lib/warning")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(17));e.exports=function(e){return function e(n,t){switch(typeof n){case"undefined":return"undefined";case"object":if(null===n)return"null";if(Array.isArray(n)){if(0===n.length)return"[]";var o,i="[\n",c=t+" ",a=(0,r.default)(n);try{for(a.s();!(o=a.n()).done;){var s=o.value;i+=c+e(s,c)+",\n"}}catch(e){a.e(e)}finally{a.f()}return i+=t+"]"}if("string"==typeof n.kind){for(var u="".concat(n.kind," {\n"),l=t+" ",f=0,p=Object.entries(n);f<p.length;f++){var d=p[f],g=d[0],x=d[1];"kind"!==g&&(u+="".concat(l).concat(g,": ").concat(e(x,l),",\n"))}return u+=t+"}"}if("function"==typeof n.toJSON)return e(n.toJSON(),t);for(var h="{\n",y=t+" ",v=0,w=Object.entries(n);v<w.length;v++){var b=w[v],m=b[0],W=b[1];h+="".concat(y).concat(JSON.stringify(m),": ").concat(e(W,y),",\n")}return h+=t+"}";case"string":case"number":case"boolean":return JSON.stringify(n,null,2).replace("\n","\n"+t);default:throw new Error("printAST doesn't handle values where "+"typeof value === '".concat(typeof n,"'."))}}(e,"")}},function(e,n){e.exports=require("@babel/runtime/helpers/createForOfIteratorHelper")},function(e,n,t){"use strict";e.exports=function e(n){if(Array.isArray(n))return n.map(e);if(null!=n&&"object"==typeof n){var t={};for(var r in n)t[r]=e(n[r]);return t}return n}},function(e,n,t){"use strict";e.exports=function(e){var n=new Map,t=jest.fn((function(e){var t,r=null!==(t=n.get(e))&&void 0!==t?t:NaN;1===r?n.delete(e):n.set(e,r-1)}));return e.retain=jest.fn((function(e){var r,o=e.request.identifier,i=null!==(r=n.get(o))&&void 0!==r?r:0;n.set(o,i+1);var c=!1;return{dispose:function(){c||t(o),c=!0}}})),{release_DEPRECATED:t,isOperationRetained:function(e){var t,r=e.request.identifier;return(null!==(t=n.get(r))&&void 0!==t?t:0)>0}}}},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("warning","expectToWarn",(function(e){jest.mock("fbjs/lib/warning",(function(){return jest.fn((function(n,t){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];if(!n){var c=0,a=t.replace(/%s/g,(function(){return String(o[c++])}));e(a)}}))}))}));e.exports={disallowWarnings:function(){r.disallowMessages()},expectWarningWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectToWarn:function(e,n){return r.expectMessage(e,n)},expectToWarnMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n){e.exports=require("relay-test-utils")}]);
|
4
|
+
module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=3)}([function(e,n){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(5)),o=console.error;e.exports={createConsoleInterceptionSystem:function(e,n,t){var i=!1,c=[],a=[],s=[],u=e.charAt(0).toUpperCase()+e.slice(1),l=u+"s",f="disallow".concat(u,"s");function p(e){var n=c.findIndex((function(n){return e.startsWith(n)})),t=a.findIndex((function(n){return e.startsWith(n)}));if(s.length>0&&e.startsWith(s[0]))s.shift();else if(n>=0)c.splice(n,1);else{if(!(t>=0))throw o("Unexpected ".concat(u,": ")+e),new Error("".concat(u,": ")+e);a.splice(t,1)}}function d(t,o){if(s.length>0)throw new Error("Cannot nest ".concat(n,"() calls."));s.push.apply(s,(0,r.default)(t));var i=o();if(s.length>0){var c=s.toString();throw s.length=0,new Error("Expected ".concat(e," in callback: ").concat(c))}return i}return{disallowMessages:function(){if(i)throw new Error("".concat(f," should be called only once."));i=!0,t(p),afterEach((function(){if(a.length=0,s.length=0,c.length>0){var n=new Error("Some ".concat(c.length," expected ").concat(e,"s where not triggered:\n\n")+Array.from(c,(function(e){return" * ".concat(e)})).join("\n")+"\n");throw c.length=0,n}}))},expectMessageWillFire:function(e,n){if(!i)throw new Error("".concat(f," needs to be called before expect").concat(l,"WillFire"));for(var t=!0===(null==n?void 0:n.optional),r=0;r<(null!==(o=null==n?void 0:n.count)&&void 0!==o?o:1);r++){var o;(t?a:c).push(e)}},expectMessage:function(e,n){return d([e],n)},expectMessageMany:d}}}},function(e,n){e.exports=require("relay-runtime")},function(e,n,t){"use strict";var r=t(4),o=r.disallowConsoleErrors,i=r.expectConsoleError,c=r.expectConsoleErrorsMany,a=r.expectConsoleErrorWillFire,s=t(6),u=s.disallowConsoleWarnings,l=s.expectConsoleWarning,f=s.expectConsoleWarningsMany,p=s.expectConsoleWarningWillFire,d=t(7),g=t(9),x=g.FIXTURE_TAG,h=g.generateTestsFromFixtures,y=t(14),v=t(16),w=t(18),b=t(19),m=t(20),W=m.disallowWarnings,E=m.expectToWarn,C=m.expectToWarnMany,M=m.expectWarningWillFire,F=t(21),j=F.createMockEnvironment,S=F.unwrapContainer;e.exports={cannotReadPropertyOfUndefined__DEPRECATED:function(e){var n=process.version.match(/^v(\d+)\./),t=null==n?null:parseInt(n[1],10);return null==t||t<16?"Cannot read property '".concat(e,"' of undefined"):"Cannot read properties of undefined (reading '".concat(e,"')")},createMockEnvironment:j,describeWithFeatureFlags:d,disallowConsoleErrors:o,disallowConsoleWarnings:u,disallowWarnings:W,expectConsoleError:i,expectConsoleErrorsMany:c,expectConsoleErrorWillFire:a,expectConsoleWarningWillFire:p,expectConsoleWarning:l,expectConsoleWarningsMany:f,expectToWarn:E,expectToWarnMany:C,expectWarningWillFire:M,FIXTURE_TAG:x,generateTestsFromFixtures:h,matchers:y,printAST:v,simpleClone:w,trackRetentionForEnvironment:b,unwrapContainer:S}},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("error","expectConsoleError",(function(e){jest.spyOn(console,"error").mockImplementation(e)}));e.exports={disallowConsoleErrors:function(){r.disallowMessages()},expectConsoleErrorWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectConsoleError:function(e,n){return r.expectMessage(e,n)},expectConsoleErrorsMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("warning","expectConsoleWarning",(function(e){jest.spyOn(console,"warn").mockImplementation(e)}));e.exports={disallowConsoleWarnings:function(){r.disallowMessages()},expectConsoleWarningWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectConsoleWarning:function(e,n){return r.expectMessage(e,n)},expectConsoleWarningsMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n,t){"use strict";var r=(0,t(0).default)(t(8));e.exports=function(e,n,o){describe.each(e)("".concat(n," - Feature flags: %o"),(function(e){var n;beforeEach((function(){var o=t(2).RelayFeatureFlags;n=(0,r.default)({},o),Object.assign(o,e)})),afterEach((function(){var e=t(2).RelayFeatureFlags;Object.assign(e,n)})),o()}))}},function(e,n){e.exports=require("@babel/runtime/helpers/objectSpread2")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(10)),o=t(11),i=t(12),c=t(13),a=Symbol.for("FIXTURE_TAG");expect.addSnapshotSerializer({print:function(e){return Object.keys(e).map((function(n){return"~~~~~~~~~~ ".concat(n.toUpperCase()," ~~~~~~~~~~\n").concat(e[n])})).join("\n")},test:function(e){return e&&!0===e[a]}}),e.exports={generateTestsFromFixtures:function(e,n){var t=i.readdirSync(e);test("has fixtures in ".concat(e),(function(){expect(t.length>0).toBe(!0)}));var s=t.filter((function(e){return e.startsWith("only.")}));s.length&&(test.skip.each(t.filter((function(e){return!e.startsWith("only.")})))("matches expected output: %s",(function(){})),t=s),test.each(t)("matches expected output: %s",(function(t){var s,u=i.readFileSync(c.join(e,t),"utf8"),l=o(u,n,t);expect((s={},(0,r.default)(s,a,!0),(0,r.default)(s,"input",u),(0,r.default)(s,"output",l),s)).toMatchSnapshot()}))},FIXTURE_TAG:a}},function(e,n){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,n,t){"use strict";e.exports=function(e,n,t){if(/^# *expected-to-throw/.test(e)||/\.error\.\w+$/.test(t)){var r;try{r=n(e)}catch(e){return"THROWN EXCEPTION:\n\n".concat(e.toString())}throw new Error("Expected test file '".concat(t,"' to throw, but it passed:\n").concat(r))}return n(e)}},function(e,n){e.exports=require("fs")},function(e,n){e.exports=require("path")},function(e,n,t){"use strict";e.exports={toBeDeeplyFrozen:function(e){return function e(n){if(expect(Object.isFrozen(n)).toBe(!0),Array.isArray(n))n.forEach((function(n){return e(n)}));else if("object"==typeof n&&null!==n)for(var t in n)e(n[t])}(e),{pass:!0}},toWarn:function(e,n){var r=this.isNot;function o(e){return e instanceof RegExp?e.toString():JSON.stringify(e)}function i(e){return"["+e.map(o).join(", ")+"]"}function c(e){return e.length?e.map((function(e){return i([!!e[0]].concat(e.slice(1)))})).join(", "):"[]"}var a=t(15);if(!a.mock)throw new Error("toWarn(): Requires `jest.mock('warning')`.");var s=a.mock.calls.length;e();var u=a.mock.calls.slice(s);return n?(Array.isArray(n)||(n=[n]),{pass:!!u.find((function(e){return e.length===n.length+1&&e.every((function(e,t){if(!t)return!e;var r=n[t-1];return r instanceof RegExp?r.test(e):e===r}))})),message:function(){return"Expected ".concat(r?"not ":"","to warn: ")+"".concat(i([!1].concat(n))," but ")+"`warning` received the following calls: "+"".concat(c(u),".")}}):{pass:!!u.filter((function(e){return!e[0]})).length,message:function(){return"Expected ".concat(r?"not ":"","to warn but ")+"`warning` received the following calls: "+"".concat(c(u),".")}}}}},function(e,n){e.exports=require("fbjs/lib/warning")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(17));e.exports=function(e){return function e(n,t){switch(typeof n){case"undefined":return"undefined";case"object":if(null===n)return"null";if(Array.isArray(n)){if(0===n.length)return"[]";var o,i="[\n",c=t+" ",a=(0,r.default)(n);try{for(a.s();!(o=a.n()).done;){var s=o.value;i+=c+e(s,c)+",\n"}}catch(e){a.e(e)}finally{a.f()}return i+=t+"]"}if("string"==typeof n.kind){for(var u="".concat(n.kind," {\n"),l=t+" ",f=0,p=Object.entries(n);f<p.length;f++){var d=p[f],g=d[0],x=d[1];"kind"!==g&&(u+="".concat(l).concat(g,": ").concat(e(x,l),",\n"))}return u+=t+"}"}if("function"==typeof n.toJSON)return e(n.toJSON(),t);for(var h="{\n",y=t+" ",v=0,w=Object.entries(n);v<w.length;v++){var b=w[v],m=b[0],W=b[1];h+="".concat(y).concat(JSON.stringify(m),": ").concat(e(W,y),",\n")}return h+=t+"}";case"string":case"number":case"boolean":return JSON.stringify(n,null,2).replace("\n","\n"+t);default:throw new Error("printAST doesn't handle values where "+"typeof value === '".concat(typeof n,"'."))}}(e,"")}},function(e,n){e.exports=require("@babel/runtime/helpers/createForOfIteratorHelper")},function(e,n,t){"use strict";e.exports=function e(n){if(Array.isArray(n))return n.map(e);if(null!=n&&"object"==typeof n){var t={};for(var r in n)t[r]=e(n[r]);return t}return n}},function(e,n,t){"use strict";e.exports=function(e){var n=new Map,t=jest.fn((function(e){var t,r=null!==(t=n.get(e))&&void 0!==t?t:NaN;1===r?n.delete(e):n.set(e,r-1)}));return e.retain=jest.fn((function(e){var r,o=e.request.identifier,i=null!==(r=n.get(o))&&void 0!==r?r:0;n.set(o,i+1);var c=!1;return{dispose:function(){c||t(o),c=!0}}})),{release_DEPRECATED:t,isOperationRetained:function(e){var t,r=e.request.identifier;return(null!==(t=n.get(r))&&void 0!==t?t:0)>0}}}},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("warning","expectToWarn",(function(e){jest.mock("fbjs/lib/warning",(function(){return jest.fn((function(n,t){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];if(!n){var c=0,a=t.replace(/%s/g,(function(){return String(o[c++])}));e(a)}}))}))}));e.exports={disallowWarnings:function(){r.disallowMessages()},expectWarningWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectToWarn:function(e,n){return r.expectMessage(e,n)},expectToWarnMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n){e.exports=require("relay-test-utils")}]);
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/**
|
2
|
-
* Relay
|
2
|
+
* Relay v16.0.0
|
3
3
|
*
|
4
4
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
5
5
|
*
|
6
6
|
* This source code is licensed under the MIT license found in the
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
8
8
|
*/
|
9
|
-
module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=3)}([function(e,n){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(5)),o=console.error;e.exports={createConsoleInterceptionSystem:function(e,n,t){var i=!1,c=[],a=[],s=[],u=e.charAt(0).toUpperCase()+e.slice(1),l=u+"s",f="disallow".concat(u,"s");function p(e){var n=c.findIndex((function(n){return e.startsWith(n)})),t=a.findIndex((function(n){return e.startsWith(n)}));if(s.length>0&&e.startsWith(s[0]))s.shift();else if(n>=0)c.splice(n,1);else{if(!(t>=0))throw o("Unexpected ".concat(u,": ")+e),new Error("".concat(u,": ")+e);a.splice(t,1)}}function d(t,o){if(s.length>0)throw new Error("Cannot nest ".concat(n,"() calls."));s.push.apply(s,(0,r.default)(t));var i=o();if(s.length>0){var c=s.toString();throw s.length=0,new Error("Expected ".concat(e," in callback: ").concat(c))}return i}return{disallowMessages:function(){if(i)throw new Error("".concat(f," should be called only once."));i=!0,t(p),afterEach((function(){if(a.length=0,s.length=0,c.length>0){var n=new Error("Some ".concat(c.length," expected ").concat(e,"s where not triggered:\n\n")+Array.from(c,(function(e){return" * ".concat(e)})).join("\n")+"\n");throw c.length=0,n}}))},expectMessageWillFire:function(e,n){if(!i)throw new Error("".concat(f," needs to be called before expect").concat(l,"WillFire"));for(var t=!0===(null==n?void 0:n.optional),r=0;r<(null!==(o=null==n?void 0:n.count)&&void 0!==o?o:1);r++){var o;(t?a:c).push(e)}},expectMessage:function(e,n){return d([e],n)},expectMessageMany:d}}}},function(e,n){e.exports=require("relay-runtime")},function(e,n,t){"use strict";var r=t(4),o=r.disallowConsoleErrors,i=r.expectConsoleError,c=r.expectConsoleErrorsMany,a=r.expectConsoleErrorWillFire,s=t(6),u=s.disallowConsoleWarnings,l=s.expectConsoleWarning,f=s.expectConsoleWarningsMany,p=s.expectConsoleWarningWillFire,d=t(7),g=t(9),x=g.FIXTURE_TAG,h=g.generateTestsFromFixtures,y=t(14),v=t(16),w=t(18),b=t(19),m=t(20),W=m.disallowWarnings,E=m.expectToWarn,C=m.expectToWarnMany,M=m.expectWarningWillFire,F=t(21),j=F.createMockEnvironment,S=F.unwrapContainer;e.exports={cannotReadPropertyOfUndefined__DEPRECATED:function(e){return process.version.match(/^v16\.(.+)$/)?"Cannot read properties of undefined (reading '".concat(e,"')"):"Cannot read property '".concat(e,"' of undefined")},createMockEnvironment:j,describeWithFeatureFlags:d,disallowConsoleErrors:o,disallowConsoleWarnings:u,disallowWarnings:W,expectConsoleError:i,expectConsoleErrorsMany:c,expectConsoleErrorWillFire:a,expectConsoleWarningWillFire:p,expectConsoleWarning:l,expectConsoleWarningsMany:f,expectToWarn:E,expectToWarnMany:C,expectWarningWillFire:M,FIXTURE_TAG:x,generateTestsFromFixtures:h,matchers:y,printAST:v,simpleClone:w,trackRetentionForEnvironment:b,unwrapContainer:S}},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("error","expectConsoleError",(function(e){jest.spyOn(console,"error").mockImplementation(e)}));e.exports={disallowConsoleErrors:function(){r.disallowMessages()},expectConsoleErrorWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectConsoleError:function(e,n){return r.expectMessage(e,n)},expectConsoleErrorsMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("warning","expectConsoleWarning",(function(e){jest.spyOn(console,"warn").mockImplementation(e)}));e.exports={disallowConsoleWarnings:function(){r.disallowMessages()},expectConsoleWarningWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectConsoleWarning:function(e,n){return r.expectMessage(e,n)},expectConsoleWarningsMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n,t){"use strict";var r=(0,t(0).default)(t(8));e.exports=function(e,n,o){describe.each(e)("".concat(n," - Feature flags: %o"),(function(e){var n;beforeEach((function(){var o=t(2).RelayFeatureFlags;n=(0,r.default)({},o),Object.assign(o,e)})),afterEach((function(){var e=t(2).RelayFeatureFlags;Object.assign(e,n)})),o()}))}},function(e,n){e.exports=require("@babel/runtime/helpers/objectSpread2")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(10)),o=t(11),i=t(12),c=t(13),a=Symbol.for("FIXTURE_TAG");expect.addSnapshotSerializer({print:function(e){return Object.keys(e).map((function(n){return"~~~~~~~~~~ ".concat(n.toUpperCase()," ~~~~~~~~~~\n").concat(e[n])})).join("\n")},test:function(e){return e&&!0===e[a]}}),e.exports={generateTestsFromFixtures:function(e,n){var t=i.readdirSync(e);test("has fixtures in ".concat(e),(function(){expect(t.length>0).toBe(!0)}));var s=t.filter((function(e){return e.startsWith("only.")}));s.length&&(test.skip.each(t.filter((function(e){return!e.startsWith("only.")})))("matches expected output: %s",(function(){})),t=s),test.each(t)("matches expected output: %s",(function(t){var s,u=i.readFileSync(c.join(e,t),"utf8"),l=o(u,n,t);expect((s={},(0,r.default)(s,a,!0),(0,r.default)(s,"input",u),(0,r.default)(s,"output",l),s)).toMatchSnapshot()}))},FIXTURE_TAG:a}},function(e,n){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,n,t){"use strict";e.exports=function(e,n,t){if(/^# *expected-to-throw/.test(e)||/\.error\.\w+$/.test(t)){var r;try{r=n(e)}catch(e){return"THROWN EXCEPTION:\n\n".concat(e.toString())}throw new Error("Expected test file '".concat(t,"' to throw, but it passed:\n").concat(r))}return n(e)}},function(e,n){e.exports=require("fs")},function(e,n){e.exports=require("path")},function(e,n,t){"use strict";e.exports={toBeDeeplyFrozen:function(e){return function e(n){if(expect(Object.isFrozen(n)).toBe(!0),Array.isArray(n))n.forEach((function(n){return e(n)}));else if("object"==typeof n&&null!==n)for(var t in n)e(n[t])}(e),{pass:!0}},toWarn:function(e,n){var r=this.isNot;function o(e){return e instanceof RegExp?e.toString():JSON.stringify(e)}function i(e){return"["+e.map(o).join(", ")+"]"}function c(e){return e.length?e.map((function(e){return i([!!e[0]].concat(e.slice(1)))})).join(", "):"[]"}var a=t(15);if(!a.mock)throw new Error("toWarn(): Requires `jest.mock('warning')`.");var s=a.mock.calls.length;e();var u=a.mock.calls.slice(s);return n?(Array.isArray(n)||(n=[n]),{pass:!!u.find((function(e){return e.length===n.length+1&&e.every((function(e,t){if(!t)return!e;var r=n[t-1];return r instanceof RegExp?r.test(e):e===r}))})),message:function(){return"Expected ".concat(r?"not ":"","to warn: ")+"".concat(i([!1].concat(n))," but ")+"`warning` received the following calls: "+"".concat(c(u),".")}}):{pass:!!u.filter((function(e){return!e[0]})).length,message:function(){return"Expected ".concat(r?"not ":"","to warn but ")+"`warning` received the following calls: "+"".concat(c(u),".")}}}}},function(e,n){e.exports=require("fbjs/lib/warning")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(17));e.exports=function(e){return function e(n,t){switch(typeof n){case"undefined":return"undefined";case"object":if(null===n)return"null";if(Array.isArray(n)){if(0===n.length)return"[]";var o,i="[\n",c=t+" ",a=(0,r.default)(n);try{for(a.s();!(o=a.n()).done;){var s=o.value;i+=c+e(s,c)+",\n"}}catch(e){a.e(e)}finally{a.f()}return i+=t+"]"}if("string"==typeof n.kind){for(var u="".concat(n.kind," {\n"),l=t+" ",f=0,p=Object.entries(n);f<p.length;f++){var d=p[f],g=d[0],x=d[1];"kind"!==g&&(u+="".concat(l).concat(g,": ").concat(e(x,l),",\n"))}return u+=t+"}"}if("function"==typeof n.toJSON)return e(n.toJSON(),t);for(var h="{\n",y=t+" ",v=0,w=Object.entries(n);v<w.length;v++){var b=w[v],m=b[0],W=b[1];h+="".concat(y).concat(JSON.stringify(m),": ").concat(e(W,y),",\n")}return h+=t+"}";case"string":case"number":case"boolean":return JSON.stringify(n,null,2).replace("\n","\n"+t);default:throw new Error("printAST doesn't handle values where "+"typeof value === '".concat(typeof n,"'."))}}(e,"")}},function(e,n){e.exports=require("@babel/runtime/helpers/createForOfIteratorHelper")},function(e,n,t){"use strict";e.exports=function e(n){if(Array.isArray(n))return n.map(e);if(null!=n&&"object"==typeof n){var t={};for(var r in n)t[r]=e(n[r]);return t}return n}},function(e,n,t){"use strict";e.exports=function(e){var n=new Map,t=jest.fn((function(e){var t,r=null!==(t=n.get(e))&&void 0!==t?t:NaN;1===r?n.delete(e):n.set(e,r-1)}));return e.retain=jest.fn((function(e){var r,o=e.request.identifier,i=null!==(r=n.get(o))&&void 0!==r?r:0;n.set(o,i+1);var c=!1;return{dispose:function(){c||t(o),c=!0}}})),{release_DEPRECATED:t,isOperationRetained:function(e){var t,r=e.request.identifier;return(null!==(t=n.get(r))&&void 0!==t?t:0)>0}}}},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("warning","expectToWarn",(function(e){jest.mock("fbjs/lib/warning",(function(){return jest.fn((function(n,t){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];if(!n){var c=0,a=t.replace(/%s/g,(function(){return String(o[c++])}));e(a)}}))}))}));e.exports={disallowWarnings:function(){r.disallowMessages()},expectWarningWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectToWarn:function(e,n){return r.expectMessage(e,n)},expectToWarnMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n){e.exports=require("relay-test-utils")}]);
|
9
|
+
module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=3)}([function(e,n){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(5)),o=console.error;e.exports={createConsoleInterceptionSystem:function(e,n,t){var i=!1,c=[],a=[],s=[],u=e.charAt(0).toUpperCase()+e.slice(1),l=u+"s",f="disallow".concat(u,"s");function p(e){var n=c.findIndex((function(n){return e.startsWith(n)})),t=a.findIndex((function(n){return e.startsWith(n)}));if(s.length>0&&e.startsWith(s[0]))s.shift();else if(n>=0)c.splice(n,1);else{if(!(t>=0))throw o("Unexpected ".concat(u,": ")+e),new Error("".concat(u,": ")+e);a.splice(t,1)}}function d(t,o){if(s.length>0)throw new Error("Cannot nest ".concat(n,"() calls."));s.push.apply(s,(0,r.default)(t));var i=o();if(s.length>0){var c=s.toString();throw s.length=0,new Error("Expected ".concat(e," in callback: ").concat(c))}return i}return{disallowMessages:function(){if(i)throw new Error("".concat(f," should be called only once."));i=!0,t(p),afterEach((function(){if(a.length=0,s.length=0,c.length>0){var n=new Error("Some ".concat(c.length," expected ").concat(e,"s where not triggered:\n\n")+Array.from(c,(function(e){return" * ".concat(e)})).join("\n")+"\n");throw c.length=0,n}}))},expectMessageWillFire:function(e,n){if(!i)throw new Error("".concat(f," needs to be called before expect").concat(l,"WillFire"));for(var t=!0===(null==n?void 0:n.optional),r=0;r<(null!==(o=null==n?void 0:n.count)&&void 0!==o?o:1);r++){var o;(t?a:c).push(e)}},expectMessage:function(e,n){return d([e],n)},expectMessageMany:d}}}},function(e,n){e.exports=require("relay-runtime")},function(e,n,t){"use strict";var r=t(4),o=r.disallowConsoleErrors,i=r.expectConsoleError,c=r.expectConsoleErrorsMany,a=r.expectConsoleErrorWillFire,s=t(6),u=s.disallowConsoleWarnings,l=s.expectConsoleWarning,f=s.expectConsoleWarningsMany,p=s.expectConsoleWarningWillFire,d=t(7),g=t(9),x=g.FIXTURE_TAG,h=g.generateTestsFromFixtures,y=t(14),v=t(16),w=t(18),b=t(19),m=t(20),W=m.disallowWarnings,E=m.expectToWarn,C=m.expectToWarnMany,M=m.expectWarningWillFire,F=t(21),j=F.createMockEnvironment,S=F.unwrapContainer;e.exports={cannotReadPropertyOfUndefined__DEPRECATED:function(e){var n=process.version.match(/^v(\d+)\./),t=null==n?null:parseInt(n[1],10);return null==t||t<16?"Cannot read property '".concat(e,"' of undefined"):"Cannot read properties of undefined (reading '".concat(e,"')")},createMockEnvironment:j,describeWithFeatureFlags:d,disallowConsoleErrors:o,disallowConsoleWarnings:u,disallowWarnings:W,expectConsoleError:i,expectConsoleErrorsMany:c,expectConsoleErrorWillFire:a,expectConsoleWarningWillFire:p,expectConsoleWarning:l,expectConsoleWarningsMany:f,expectToWarn:E,expectToWarnMany:C,expectWarningWillFire:M,FIXTURE_TAG:x,generateTestsFromFixtures:h,matchers:y,printAST:v,simpleClone:w,trackRetentionForEnvironment:b,unwrapContainer:S}},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("error","expectConsoleError",(function(e){jest.spyOn(console,"error").mockImplementation(e)}));e.exports={disallowConsoleErrors:function(){r.disallowMessages()},expectConsoleErrorWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectConsoleError:function(e,n){return r.expectMessage(e,n)},expectConsoleErrorsMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("warning","expectConsoleWarning",(function(e){jest.spyOn(console,"warn").mockImplementation(e)}));e.exports={disallowConsoleWarnings:function(){r.disallowMessages()},expectConsoleWarningWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectConsoleWarning:function(e,n){return r.expectMessage(e,n)},expectConsoleWarningsMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n,t){"use strict";var r=(0,t(0).default)(t(8));e.exports=function(e,n,o){describe.each(e)("".concat(n," - Feature flags: %o"),(function(e){var n;beforeEach((function(){var o=t(2).RelayFeatureFlags;n=(0,r.default)({},o),Object.assign(o,e)})),afterEach((function(){var e=t(2).RelayFeatureFlags;Object.assign(e,n)})),o()}))}},function(e,n){e.exports=require("@babel/runtime/helpers/objectSpread2")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(10)),o=t(11),i=t(12),c=t(13),a=Symbol.for("FIXTURE_TAG");expect.addSnapshotSerializer({print:function(e){return Object.keys(e).map((function(n){return"~~~~~~~~~~ ".concat(n.toUpperCase()," ~~~~~~~~~~\n").concat(e[n])})).join("\n")},test:function(e){return e&&!0===e[a]}}),e.exports={generateTestsFromFixtures:function(e,n){var t=i.readdirSync(e);test("has fixtures in ".concat(e),(function(){expect(t.length>0).toBe(!0)}));var s=t.filter((function(e){return e.startsWith("only.")}));s.length&&(test.skip.each(t.filter((function(e){return!e.startsWith("only.")})))("matches expected output: %s",(function(){})),t=s),test.each(t)("matches expected output: %s",(function(t){var s,u=i.readFileSync(c.join(e,t),"utf8"),l=o(u,n,t);expect((s={},(0,r.default)(s,a,!0),(0,r.default)(s,"input",u),(0,r.default)(s,"output",l),s)).toMatchSnapshot()}))},FIXTURE_TAG:a}},function(e,n){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,n,t){"use strict";e.exports=function(e,n,t){if(/^# *expected-to-throw/.test(e)||/\.error\.\w+$/.test(t)){var r;try{r=n(e)}catch(e){return"THROWN EXCEPTION:\n\n".concat(e.toString())}throw new Error("Expected test file '".concat(t,"' to throw, but it passed:\n").concat(r))}return n(e)}},function(e,n){e.exports=require("fs")},function(e,n){e.exports=require("path")},function(e,n,t){"use strict";e.exports={toBeDeeplyFrozen:function(e){return function e(n){if(expect(Object.isFrozen(n)).toBe(!0),Array.isArray(n))n.forEach((function(n){return e(n)}));else if("object"==typeof n&&null!==n)for(var t in n)e(n[t])}(e),{pass:!0}},toWarn:function(e,n){var r=this.isNot;function o(e){return e instanceof RegExp?e.toString():JSON.stringify(e)}function i(e){return"["+e.map(o).join(", ")+"]"}function c(e){return e.length?e.map((function(e){return i([!!e[0]].concat(e.slice(1)))})).join(", "):"[]"}var a=t(15);if(!a.mock)throw new Error("toWarn(): Requires `jest.mock('warning')`.");var s=a.mock.calls.length;e();var u=a.mock.calls.slice(s);return n?(Array.isArray(n)||(n=[n]),{pass:!!u.find((function(e){return e.length===n.length+1&&e.every((function(e,t){if(!t)return!e;var r=n[t-1];return r instanceof RegExp?r.test(e):e===r}))})),message:function(){return"Expected ".concat(r?"not ":"","to warn: ")+"".concat(i([!1].concat(n))," but ")+"`warning` received the following calls: "+"".concat(c(u),".")}}):{pass:!!u.filter((function(e){return!e[0]})).length,message:function(){return"Expected ".concat(r?"not ":"","to warn but ")+"`warning` received the following calls: "+"".concat(c(u),".")}}}}},function(e,n){e.exports=require("fbjs/lib/warning")},function(e,n,t){"use strict";var r=(0,t(0).default)(t(17));e.exports=function(e){return function e(n,t){switch(typeof n){case"undefined":return"undefined";case"object":if(null===n)return"null";if(Array.isArray(n)){if(0===n.length)return"[]";var o,i="[\n",c=t+" ",a=(0,r.default)(n);try{for(a.s();!(o=a.n()).done;){var s=o.value;i+=c+e(s,c)+",\n"}}catch(e){a.e(e)}finally{a.f()}return i+=t+"]"}if("string"==typeof n.kind){for(var u="".concat(n.kind," {\n"),l=t+" ",f=0,p=Object.entries(n);f<p.length;f++){var d=p[f],g=d[0],x=d[1];"kind"!==g&&(u+="".concat(l).concat(g,": ").concat(e(x,l),",\n"))}return u+=t+"}"}if("function"==typeof n.toJSON)return e(n.toJSON(),t);for(var h="{\n",y=t+" ",v=0,w=Object.entries(n);v<w.length;v++){var b=w[v],m=b[0],W=b[1];h+="".concat(y).concat(JSON.stringify(m),": ").concat(e(W,y),",\n")}return h+=t+"}";case"string":case"number":case"boolean":return JSON.stringify(n,null,2).replace("\n","\n"+t);default:throw new Error("printAST doesn't handle values where "+"typeof value === '".concat(typeof n,"'."))}}(e,"")}},function(e,n){e.exports=require("@babel/runtime/helpers/createForOfIteratorHelper")},function(e,n,t){"use strict";e.exports=function e(n){if(Array.isArray(n))return n.map(e);if(null!=n&&"object"==typeof n){var t={};for(var r in n)t[r]=e(n[r]);return t}return n}},function(e,n,t){"use strict";e.exports=function(e){var n=new Map,t=jest.fn((function(e){var t,r=null!==(t=n.get(e))&&void 0!==t?t:NaN;1===r?n.delete(e):n.set(e,r-1)}));return e.retain=jest.fn((function(e){var r,o=e.request.identifier,i=null!==(r=n.get(o))&&void 0!==r?r:0;n.set(o,i+1);var c=!1;return{dispose:function(){c||t(o),c=!0}}})),{release_DEPRECATED:t,isOperationRetained:function(e){var t,r=e.request.identifier;return(null!==(t=n.get(r))&&void 0!==t?t:0)>0}}}},function(e,n,t){"use strict";var r=(0,t(1).createConsoleInterceptionSystem)("warning","expectToWarn",(function(e){jest.mock("fbjs/lib/warning",(function(){return jest.fn((function(n,t){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];if(!n){var c=0,a=t.replace(/%s/g,(function(){return String(o[c++])}));e(a)}}))}))}));e.exports={disallowWarnings:function(){r.disallowMessages()},expectWarningWillFire:function(e,n){r.expectMessageWillFire(e,n)},expectToWarn:function(e,n){return r.expectMessage(e,n)},expectToWarnMany:function(e,n){return r.expectMessageMany(e,n)}}},function(e,n){e.exports=require("relay-test-utils")}]);
|
package/simpleClone.js.flow
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
*
|
7
7
|
* @flow
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
10
11
|
|
11
12
|
'use strict';
|
@@ -25,9 +26,9 @@ function trackRetentionForEnvironment(environment: IEnvironment): {
|
|
25
26
|
release_DEPRECATED: JestMockFn<[mixed], void>,
|
26
27
|
isOperationRetained: OperationDescriptor => boolean,
|
27
28
|
} {
|
28
|
-
const retainCountsByOperation = new Map();
|
29
|
+
const retainCountsByOperation = new Map<mixed, number>();
|
29
30
|
|
30
|
-
const release = jest.fn(id => {
|
31
|
+
const release = jest.fn((id: mixed) => {
|
31
32
|
const existing = retainCountsByOperation.get(id) ?? NaN;
|
32
33
|
if (existing === 1) {
|
33
34
|
retainCountsByOperation.delete(id);
|
@@ -37,6 +38,7 @@ function trackRetentionForEnvironment(environment: IEnvironment): {
|
|
37
38
|
});
|
38
39
|
|
39
40
|
// $FlowFixMe[cannot-write] safe to do for mocking
|
41
|
+
// $FlowFixMe[missing-local-annot] error found when enabling Flow LTI mode
|
40
42
|
environment.retain = jest.fn(operation => {
|
41
43
|
const id = operation.request.identifier;
|
42
44
|
const existing = retainCountsByOperation.get(id) ?? 0;
|
package/warnings.js.flow
CHANGED