relay-test-utils-internal 13.2.0 → 14.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/consoleError.js.flow +7 -2
- package/consoleErrorsAndWarnings.js.flow +24 -6
- package/consoleWarning.js.flow +70 -0
- package/index.js +1 -1
- package/index.js.flow +12 -0
- package/lib/consoleError.js +2 -2
- package/lib/consoleErrorsAndWarnings.js +18 -5
- package/lib/consoleWarning.js +63 -0
- package/lib/index.js +24 -11
- package/lib/testschema.graphql +0 -26
- package/lib/trackRetentionForEnvironment.js +65 -0
- package/lib/warnings.js +2 -2
- package/package.json +2 -2
- package/relay-test-utils-internal.js +2 -2
- package/relay-test-utils-internal.min.js +2 -2
- package/simpleClone.js.flow +1 -1
- package/trackRetentionForEnvironment.js.flow +65 -0
- package/warnings.js.flow +7 -2
package/consoleError.js.flow
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
|
14
14
|
/* global jest */
|
15
15
|
|
16
|
+
import type {WillFireOptions} from './consoleErrorsAndWarnings';
|
17
|
+
|
16
18
|
const {createConsoleInterceptionSystem} = require('./consoleErrorsAndWarnings');
|
17
19
|
|
18
20
|
const consoleErrorsSystem = createConsoleInterceptionSystem(
|
@@ -38,8 +40,11 @@ function disallowConsoleErrors(): void {
|
|
38
40
|
* Expect an error with the given message. If the message isn't fired in the
|
39
41
|
* current test, the test will fail.
|
40
42
|
*/
|
41
|
-
function expectConsoleErrorWillFire(
|
42
|
-
|
43
|
+
function expectConsoleErrorWillFire(
|
44
|
+
message: string,
|
45
|
+
options?: WillFireOptions,
|
46
|
+
): void {
|
47
|
+
consoleErrorsSystem.expectMessageWillFire(message, options);
|
43
48
|
}
|
44
49
|
|
45
50
|
/**
|
@@ -11,11 +11,16 @@
|
|
11
11
|
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
/* global
|
14
|
+
/* global afterEach */
|
15
|
+
|
16
|
+
export type WillFireOptions = {
|
17
|
+
count?: number,
|
18
|
+
optional?: boolean,
|
19
|
+
};
|
15
20
|
|
16
21
|
type API = $ReadOnly<{|
|
17
22
|
disallowMessages: () => void,
|
18
|
-
expectMessageWillFire: string => void,
|
23
|
+
expectMessageWillFire: (string, void | WillFireOptions) => void,
|
19
24
|
expectMessage: <T>(string, () => T) => T,
|
20
25
|
expectMessageMany: <T>(Array<string>, () => T) => T,
|
21
26
|
|}>;
|
@@ -29,6 +34,7 @@ function createConsoleInterceptionSystem(
|
|
29
34
|
): API {
|
30
35
|
let installed = false;
|
31
36
|
const expectedMessages: Array<string> = [];
|
37
|
+
const optionalMessages: Array<string> = [];
|
32
38
|
const contextualExpectedMessage: Array<string> = [];
|
33
39
|
|
34
40
|
const typenameCap = typename.charAt(0).toUpperCase() + typename.slice(1);
|
@@ -39,13 +45,18 @@ function createConsoleInterceptionSystem(
|
|
39
45
|
const index = expectedMessages.findIndex(expected =>
|
40
46
|
message.startsWith(expected),
|
41
47
|
);
|
48
|
+
const optionalIndex = optionalMessages.findIndex(expected =>
|
49
|
+
message.startsWith(expected),
|
50
|
+
);
|
42
51
|
if (
|
43
52
|
contextualExpectedMessage.length > 0 &&
|
44
|
-
contextualExpectedMessage[0]
|
53
|
+
message.startsWith(contextualExpectedMessage[0])
|
45
54
|
) {
|
46
55
|
contextualExpectedMessage.shift();
|
47
56
|
} else if (index >= 0) {
|
48
57
|
expectedMessages.splice(index, 1);
|
58
|
+
} else if (optionalIndex >= 0) {
|
59
|
+
optionalMessages.splice(optionalIndex, 1);
|
49
60
|
} else {
|
50
61
|
// log to console in case the error gets swallowed somewhere
|
51
62
|
originalConsoleError(`Unexpected ${typenameCap}: ` + message);
|
@@ -61,10 +72,11 @@ function createConsoleInterceptionSystem(
|
|
61
72
|
setUpMock(handleMessage);
|
62
73
|
|
63
74
|
afterEach(() => {
|
75
|
+
optionalMessages.length = 0;
|
64
76
|
contextualExpectedMessage.length = 0;
|
65
77
|
if (expectedMessages.length > 0) {
|
66
78
|
const error = new Error(
|
67
|
-
`Some expected ${typename}s where not triggered:\n\n` +
|
79
|
+
`Some ${expectedMessages.length} expected ${typename}s where not triggered:\n\n` +
|
68
80
|
Array.from(expectedMessages, message => ` * ${message}`).join(
|
69
81
|
'\n',
|
70
82
|
) +
|
@@ -76,13 +88,19 @@ function createConsoleInterceptionSystem(
|
|
76
88
|
});
|
77
89
|
}
|
78
90
|
|
79
|
-
function expectMessageWillFire(
|
91
|
+
function expectMessageWillFire(
|
92
|
+
message: string,
|
93
|
+
options?: WillFireOptions,
|
94
|
+
): void {
|
80
95
|
if (!installed) {
|
81
96
|
throw new Error(
|
82
97
|
`${installerName} needs to be called before expect${typenameCapPlural}WillFire`,
|
83
98
|
);
|
84
99
|
}
|
85
|
-
|
100
|
+
const optional = options?.optional === true; // avoid "sketchy null check"
|
101
|
+
for (let i = 0; i < (options?.count ?? 1); i++) {
|
102
|
+
(optional ? optionalMessages : expectedMessages).push(message);
|
103
|
+
}
|
86
104
|
}
|
87
105
|
|
88
106
|
function expectMessage<T>(message: string, fn: () => T): T {
|
@@ -0,0 +1,70 @@
|
|
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
|
+
* @flow strict-local
|
9
|
+
* @format
|
10
|
+
*/
|
11
|
+
|
12
|
+
'use strict';
|
13
|
+
|
14
|
+
/* global jest */
|
15
|
+
|
16
|
+
import type {WillFireOptions} from './consoleErrorsAndWarnings';
|
17
|
+
|
18
|
+
const {createConsoleInterceptionSystem} = require('./consoleErrorsAndWarnings');
|
19
|
+
|
20
|
+
const consoleWarningsSystem = createConsoleInterceptionSystem(
|
21
|
+
'warning',
|
22
|
+
'expectConsoleWarning',
|
23
|
+
impl => {
|
24
|
+
jest.spyOn(console, 'warn').mockImplementation(impl);
|
25
|
+
},
|
26
|
+
);
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Mocks console.warn so that warnings printed to the console are instead thrown.
|
30
|
+
* Any expected warnings need to be explicitly expected with `expectConsoleWarningWillFire(message)`.
|
31
|
+
*
|
32
|
+
* NOTE: This should be called on top of a test file. The test should NOT
|
33
|
+
* use `jest.resetModules()` or manually mock `console`.
|
34
|
+
*/
|
35
|
+
function disallowConsoleWarnings(): void {
|
36
|
+
consoleWarningsSystem.disallowMessages();
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Expect a warning with the given message. If the message isn't fired in the
|
41
|
+
* current test, the test will fail.
|
42
|
+
*/
|
43
|
+
function expectConsoleWarningWillFire(
|
44
|
+
message: string,
|
45
|
+
options?: WillFireOptions,
|
46
|
+
): void {
|
47
|
+
consoleWarningsSystem.expectMessageWillFire(message, options);
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Expect the callback `fn` to print a warning with the message, and otherwise fail.
|
52
|
+
*/
|
53
|
+
function expectConsoleWarning<T>(message: string, fn: () => T): T {
|
54
|
+
return consoleWarningsSystem.expectMessage(message, fn);
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Expect the callback `fn` to trigger all console warnings (in sequence),
|
59
|
+
* and otherwise fail.
|
60
|
+
*/
|
61
|
+
function expectConsoleWarningsMany<T>(messages: Array<string>, fn: () => T): T {
|
62
|
+
return consoleWarningsSystem.expectMessageMany(messages, fn);
|
63
|
+
}
|
64
|
+
|
65
|
+
module.exports = {
|
66
|
+
disallowConsoleWarnings,
|
67
|
+
expectConsoleWarningWillFire,
|
68
|
+
expectConsoleWarning,
|
69
|
+
expectConsoleWarningsMany,
|
70
|
+
};
|
package/index.js
CHANGED
package/index.js.flow
CHANGED
@@ -18,6 +18,12 @@ const {
|
|
18
18
|
expectConsoleErrorsMany,
|
19
19
|
expectConsoleErrorWillFire,
|
20
20
|
} = require('./consoleError');
|
21
|
+
const {
|
22
|
+
disallowConsoleWarnings,
|
23
|
+
expectConsoleWarning,
|
24
|
+
expectConsoleWarningsMany,
|
25
|
+
expectConsoleWarningWillFire,
|
26
|
+
} = require('./consoleWarning');
|
21
27
|
const describeWithFeatureFlags = require('./describeWithFeatureFlags');
|
22
28
|
const {
|
23
29
|
FIXTURE_TAG,
|
@@ -26,6 +32,7 @@ const {
|
|
26
32
|
const Matchers = require('./Matchers');
|
27
33
|
const printAST = require('./printAST');
|
28
34
|
const simpleClone = require('./simpleClone');
|
35
|
+
const trackRetentionForEnvironment = require('./trackRetentionForEnvironment');
|
29
36
|
const {
|
30
37
|
disallowWarnings,
|
31
38
|
expectToWarn,
|
@@ -57,10 +64,14 @@ module.exports = {
|
|
57
64
|
createMockEnvironment,
|
58
65
|
describeWithFeatureFlags,
|
59
66
|
disallowConsoleErrors,
|
67
|
+
disallowConsoleWarnings,
|
60
68
|
disallowWarnings,
|
61
69
|
expectConsoleError,
|
62
70
|
expectConsoleErrorsMany,
|
63
71
|
expectConsoleErrorWillFire,
|
72
|
+
expectConsoleWarningWillFire,
|
73
|
+
expectConsoleWarning,
|
74
|
+
expectConsoleWarningsMany,
|
64
75
|
expectToWarn,
|
65
76
|
expectToWarnMany,
|
66
77
|
expectWarningWillFire,
|
@@ -69,5 +80,6 @@ module.exports = {
|
|
69
80
|
matchers: Matchers,
|
70
81
|
printAST,
|
71
82
|
simpleClone,
|
83
|
+
trackRetentionForEnvironment,
|
72
84
|
unwrapContainer,
|
73
85
|
};
|
package/lib/consoleError.js
CHANGED
@@ -34,8 +34,8 @@ function disallowConsoleErrors() {
|
|
34
34
|
*/
|
35
35
|
|
36
36
|
|
37
|
-
function expectConsoleErrorWillFire(message) {
|
38
|
-
consoleErrorsSystem.expectMessageWillFire(message);
|
37
|
+
function expectConsoleErrorWillFire(message, options) {
|
38
|
+
consoleErrorsSystem.expectMessageWillFire(message, options);
|
39
39
|
}
|
40
40
|
/**
|
41
41
|
* Expect the callback `fn` to print an error with the message, and otherwise fail.
|
@@ -9,7 +9,7 @@
|
|
9
9
|
* @format
|
10
10
|
*/
|
11
11
|
'use strict';
|
12
|
-
/* global
|
12
|
+
/* global afterEach */
|
13
13
|
|
14
14
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
15
15
|
|
@@ -20,6 +20,7 @@ var originalConsoleError = console.error;
|
|
20
20
|
function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock) {
|
21
21
|
var installed = false;
|
22
22
|
var expectedMessages = [];
|
23
|
+
var optionalMessages = [];
|
23
24
|
var contextualExpectedMessage = [];
|
24
25
|
var typenameCap = typename.charAt(0).toUpperCase() + typename.slice(1);
|
25
26
|
var typenameCapPlural = typenameCap + 's';
|
@@ -29,11 +30,16 @@ function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock
|
|
29
30
|
var index = expectedMessages.findIndex(function (expected) {
|
30
31
|
return message.startsWith(expected);
|
31
32
|
});
|
33
|
+
var optionalIndex = optionalMessages.findIndex(function (expected) {
|
34
|
+
return message.startsWith(expected);
|
35
|
+
});
|
32
36
|
|
33
|
-
if (contextualExpectedMessage.length > 0 && contextualExpectedMessage[0]
|
37
|
+
if (contextualExpectedMessage.length > 0 && message.startsWith(contextualExpectedMessage[0])) {
|
34
38
|
contextualExpectedMessage.shift();
|
35
39
|
} else if (index >= 0) {
|
36
40
|
expectedMessages.splice(index, 1);
|
41
|
+
} else if (optionalIndex >= 0) {
|
42
|
+
optionalMessages.splice(optionalIndex, 1);
|
37
43
|
} else {
|
38
44
|
// log to console in case the error gets swallowed somewhere
|
39
45
|
originalConsoleError("Unexpected ".concat(typenameCap, ": ") + message);
|
@@ -49,10 +55,11 @@ function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock
|
|
49
55
|
installed = true;
|
50
56
|
setUpMock(handleMessage);
|
51
57
|
afterEach(function () {
|
58
|
+
optionalMessages.length = 0;
|
52
59
|
contextualExpectedMessage.length = 0;
|
53
60
|
|
54
61
|
if (expectedMessages.length > 0) {
|
55
|
-
var error = new Error("Some expected ".concat(typename, "s where not triggered:\n\n") + Array.from(expectedMessages, function (message) {
|
62
|
+
var error = new Error("Some ".concat(expectedMessages.length, " expected ").concat(typename, "s where not triggered:\n\n") + Array.from(expectedMessages, function (message) {
|
56
63
|
return " * ".concat(message);
|
57
64
|
}).join('\n') + '\n');
|
58
65
|
expectedMessages.length = 0;
|
@@ -61,12 +68,18 @@ function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock
|
|
61
68
|
});
|
62
69
|
}
|
63
70
|
|
64
|
-
function expectMessageWillFire(message) {
|
71
|
+
function expectMessageWillFire(message, options) {
|
65
72
|
if (!installed) {
|
66
73
|
throw new Error("".concat(installerName, " needs to be called before expect").concat(typenameCapPlural, "WillFire"));
|
67
74
|
}
|
68
75
|
|
69
|
-
|
76
|
+
var optional = (options === null || options === void 0 ? void 0 : options.optional) === true; // avoid "sketchy null check"
|
77
|
+
|
78
|
+
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
|
+
var _options$count;
|
80
|
+
|
81
|
+
(optional ? optionalMessages : expectedMessages).push(message);
|
82
|
+
}
|
70
83
|
}
|
71
84
|
|
72
85
|
function expectMessage(message, fn) {
|
@@ -0,0 +1,63 @@
|
|
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
|
+
'use strict';
|
12
|
+
/* global jest */
|
13
|
+
|
14
|
+
var _require = require('./consoleErrorsAndWarnings'),
|
15
|
+
createConsoleInterceptionSystem = _require.createConsoleInterceptionSystem;
|
16
|
+
|
17
|
+
var consoleWarningsSystem = createConsoleInterceptionSystem('warning', 'expectConsoleWarning', function (impl) {
|
18
|
+
jest.spyOn(console, 'warn').mockImplementation(impl);
|
19
|
+
});
|
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
|
+
function disallowConsoleWarnings() {
|
29
|
+
consoleWarningsSystem.disallowMessages();
|
30
|
+
}
|
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
|
+
function expectConsoleWarningWillFire(message, options) {
|
38
|
+
consoleWarningsSystem.expectMessageWillFire(message, options);
|
39
|
+
}
|
40
|
+
/**
|
41
|
+
* Expect the callback `fn` to print a warning with the message, and otherwise fail.
|
42
|
+
*/
|
43
|
+
|
44
|
+
|
45
|
+
function expectConsoleWarning(message, fn) {
|
46
|
+
return consoleWarningsSystem.expectMessage(message, fn);
|
47
|
+
}
|
48
|
+
/**
|
49
|
+
* Expect the callback `fn` to trigger all console warnings (in sequence),
|
50
|
+
* and otherwise fail.
|
51
|
+
*/
|
52
|
+
|
53
|
+
|
54
|
+
function expectConsoleWarningsMany(messages, fn) {
|
55
|
+
return consoleWarningsSystem.expectMessageMany(messages, fn);
|
56
|
+
}
|
57
|
+
|
58
|
+
module.exports = {
|
59
|
+
disallowConsoleWarnings: disallowConsoleWarnings,
|
60
|
+
expectConsoleWarningWillFire: expectConsoleWarningWillFire,
|
61
|
+
expectConsoleWarning: expectConsoleWarning,
|
62
|
+
expectConsoleWarningsMany: expectConsoleWarningsMany
|
63
|
+
};
|
package/lib/index.js
CHANGED
@@ -16,11 +16,17 @@ var _require = require('./consoleError'),
|
|
16
16
|
expectConsoleErrorsMany = _require.expectConsoleErrorsMany,
|
17
17
|
expectConsoleErrorWillFire = _require.expectConsoleErrorWillFire;
|
18
18
|
|
19
|
+
var _require2 = require('./consoleWarning'),
|
20
|
+
disallowConsoleWarnings = _require2.disallowConsoleWarnings,
|
21
|
+
expectConsoleWarning = _require2.expectConsoleWarning,
|
22
|
+
expectConsoleWarningsMany = _require2.expectConsoleWarningsMany,
|
23
|
+
expectConsoleWarningWillFire = _require2.expectConsoleWarningWillFire;
|
24
|
+
|
19
25
|
var describeWithFeatureFlags = require('./describeWithFeatureFlags');
|
20
26
|
|
21
|
-
var
|
22
|
-
FIXTURE_TAG =
|
23
|
-
generateTestsFromFixtures =
|
27
|
+
var _require3 = require('./generateTestsFromFixtures'),
|
28
|
+
FIXTURE_TAG = _require3.FIXTURE_TAG,
|
29
|
+
generateTestsFromFixtures = _require3.generateTestsFromFixtures;
|
24
30
|
|
25
31
|
var Matchers = require('./Matchers');
|
26
32
|
|
@@ -28,15 +34,17 @@ var printAST = require('./printAST');
|
|
28
34
|
|
29
35
|
var simpleClone = require('./simpleClone');
|
30
36
|
|
31
|
-
var
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
var trackRetentionForEnvironment = require('./trackRetentionForEnvironment');
|
38
|
+
|
39
|
+
var _require4 = require('./warnings'),
|
40
|
+
disallowWarnings = _require4.disallowWarnings,
|
41
|
+
expectToWarn = _require4.expectToWarn,
|
42
|
+
expectToWarnMany = _require4.expectToWarnMany,
|
43
|
+
expectWarningWillFire = _require4.expectWarningWillFire;
|
36
44
|
|
37
|
-
var
|
38
|
-
createMockEnvironment =
|
39
|
-
unwrapContainer =
|
45
|
+
var _require5 = require('relay-test-utils'),
|
46
|
+
createMockEnvironment = _require5.createMockEnvironment,
|
47
|
+
unwrapContainer = _require5.unwrapContainer; // Apparently, in node v16 (because now they are using V8 V9.something)
|
40
48
|
// the content of the TypeError has changed, and now some of our tests
|
41
49
|
// stated to fail.
|
42
50
|
// This is a temporary work-around to make test pass, but we need to
|
@@ -60,10 +68,14 @@ module.exports = {
|
|
60
68
|
createMockEnvironment: createMockEnvironment,
|
61
69
|
describeWithFeatureFlags: describeWithFeatureFlags,
|
62
70
|
disallowConsoleErrors: disallowConsoleErrors,
|
71
|
+
disallowConsoleWarnings: disallowConsoleWarnings,
|
63
72
|
disallowWarnings: disallowWarnings,
|
64
73
|
expectConsoleError: expectConsoleError,
|
65
74
|
expectConsoleErrorsMany: expectConsoleErrorsMany,
|
66
75
|
expectConsoleErrorWillFire: expectConsoleErrorWillFire,
|
76
|
+
expectConsoleWarningWillFire: expectConsoleWarningWillFire,
|
77
|
+
expectConsoleWarning: expectConsoleWarning,
|
78
|
+
expectConsoleWarningsMany: expectConsoleWarningsMany,
|
67
79
|
expectToWarn: expectToWarn,
|
68
80
|
expectToWarnMany: expectToWarnMany,
|
69
81
|
expectWarningWillFire: expectWarningWillFire,
|
@@ -72,5 +84,6 @@ module.exports = {
|
|
72
84
|
matchers: Matchers,
|
73
85
|
printAST: printAST,
|
74
86
|
simpleClone: simpleClone,
|
87
|
+
trackRetentionForEnvironment: trackRetentionForEnvironment,
|
75
88
|
unwrapContainer: unwrapContainer
|
76
89
|
};
|
package/lib/testschema.graphql
CHANGED
@@ -143,28 +143,23 @@ type Subscription {
|
|
143
143
|
}
|
144
144
|
|
145
145
|
input ActorSubscribeInput {
|
146
|
-
clientMutationId: String
|
147
146
|
subscribeeId: ID
|
148
147
|
}
|
149
148
|
|
150
149
|
input ActorNameChangeInput {
|
151
|
-
clientMutationId: String
|
152
150
|
newName: String
|
153
151
|
}
|
154
152
|
|
155
153
|
input ApplicationRequestDeleteAllInput {
|
156
|
-
clientMutationId: String
|
157
154
|
deletedRequestIds: [ID]
|
158
155
|
}
|
159
156
|
|
160
157
|
input CommentCreateInput {
|
161
|
-
clientMutationId: String
|
162
158
|
feedbackId: ID
|
163
159
|
feedback: CommentfeedbackFeedback
|
164
160
|
}
|
165
161
|
|
166
162
|
input CommentsCreateInput {
|
167
|
-
clientMutationId: String
|
168
163
|
feedbackId: ID
|
169
164
|
feedback: [CommentfeedbackFeedback]
|
170
165
|
}
|
@@ -178,40 +173,33 @@ input FeedbackcommentComment {
|
|
178
173
|
}
|
179
174
|
|
180
175
|
input CommentCreateSubscriptionInput {
|
181
|
-
clientSubscriptionId: String
|
182
176
|
feedbackId: ID
|
183
177
|
text: String
|
184
178
|
}
|
185
179
|
|
186
180
|
input CommentDeleteInput {
|
187
|
-
clientMutationId: String
|
188
181
|
commentId: ID
|
189
182
|
}
|
190
183
|
|
191
184
|
input CommentsDeleteInput {
|
192
|
-
clientMutationId: String
|
193
185
|
commentIds: [ID]
|
194
186
|
}
|
195
187
|
|
196
188
|
input FeedbackLikeInput {
|
197
|
-
clientMutationId: String
|
198
189
|
feedbackId: ID
|
199
190
|
}
|
200
191
|
|
201
192
|
input FeedbackLikeInputStrict {
|
202
193
|
userID: ID!
|
203
|
-
clientMutationId: ID!
|
204
194
|
feedbackId: ID!
|
205
195
|
description: String
|
206
196
|
}
|
207
197
|
|
208
198
|
input NodeSaveStateInput {
|
209
|
-
clientMutationId: String
|
210
199
|
nodeId: ID
|
211
200
|
}
|
212
201
|
|
213
202
|
input UpdateAllSeenStateInput {
|
214
|
-
clientMutationId: String
|
215
203
|
storyIds: [ID]
|
216
204
|
}
|
217
205
|
|
@@ -221,22 +209,18 @@ input LocationInput {
|
|
221
209
|
}
|
222
210
|
|
223
211
|
type setLocationResponsePayload {
|
224
|
-
clientMutationId: String
|
225
212
|
viewer: Viewer
|
226
213
|
}
|
227
214
|
|
228
215
|
type ActorSubscribeResponsePayload {
|
229
|
-
clientMutationId: String
|
230
216
|
subscribee: Actor
|
231
217
|
}
|
232
218
|
|
233
219
|
type ActorNameChangePayload {
|
234
|
-
clientMutationId: String
|
235
220
|
actor: Actor
|
236
221
|
}
|
237
222
|
|
238
223
|
type ApplicationRequestDeleteAllResponsePayload {
|
239
|
-
clientMutationId: String
|
240
224
|
deletedRequestIds: [ID]
|
241
225
|
}
|
242
226
|
|
@@ -250,7 +234,6 @@ input CheckinSearchInput {
|
|
250
234
|
}
|
251
235
|
|
252
236
|
input StoryUpdateInput {
|
253
|
-
clientMutationId: String
|
254
237
|
body: InputText
|
255
238
|
}
|
256
239
|
|
@@ -334,7 +317,6 @@ type ConfigCreateSubscriptResponsePayload {
|
|
334
317
|
}
|
335
318
|
|
336
319
|
type CommentCreateResponsePayload {
|
337
|
-
clientMutationId: String
|
338
320
|
comment: Comment
|
339
321
|
feedback: Feedback
|
340
322
|
feedbackCommentEdge: CommentsEdge
|
@@ -342,7 +324,6 @@ type CommentCreateResponsePayload {
|
|
342
324
|
}
|
343
325
|
|
344
326
|
type CommentsCreateResponsePayload {
|
345
|
-
clientMutationId: String
|
346
327
|
comments: [Comment]
|
347
328
|
feedback: [Feedback]
|
348
329
|
feedbackCommentEdges: [CommentsEdge]
|
@@ -350,19 +331,16 @@ type CommentsCreateResponsePayload {
|
|
350
331
|
}
|
351
332
|
|
352
333
|
type CommentDeleteResponsePayload {
|
353
|
-
clientMutationId: String
|
354
334
|
deletedCommentId: ID
|
355
335
|
feedback: Feedback
|
356
336
|
}
|
357
337
|
|
358
338
|
type CommentsDeleteResponsePayload {
|
359
|
-
clientMutationId: String
|
360
339
|
deletedCommentIds: [ID]
|
361
340
|
feedback: Feedback
|
362
341
|
}
|
363
342
|
|
364
343
|
type StoryUpdateResponsePayload {
|
365
|
-
clientMutationId: String
|
366
344
|
story: Story
|
367
345
|
}
|
368
346
|
|
@@ -478,8 +456,6 @@ type Feedback implements Node & HasJsField {
|
|
478
456
|
}
|
479
457
|
|
480
458
|
type FeedbackLikeResponsePayload {
|
481
|
-
clientMutationId: String
|
482
|
-
clientSubscriptionId: String
|
483
459
|
feedback: Feedback
|
484
460
|
}
|
485
461
|
|
@@ -938,13 +914,11 @@ type TopLevelCommentsConnection {
|
|
938
914
|
}
|
939
915
|
|
940
916
|
input UnfriendInput {
|
941
|
-
clientMutationId: String
|
942
917
|
friendId: ID
|
943
918
|
}
|
944
919
|
|
945
920
|
type UnfriendResponsePayload {
|
946
921
|
actor: Actor
|
947
|
-
clientMutationId: String
|
948
922
|
formerFriend: User
|
949
923
|
}
|
950
924
|
|
@@ -0,0 +1,65 @@
|
|
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
|
+
// flowlint ambiguous-object-type:error
|
11
|
+
'use strict';
|
12
|
+
/* global jest */
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Takes an environment and augments it with a mock implementation of `retain`
|
16
|
+
* that tracks what operations are currently retained. Also returns the Jest mock
|
17
|
+
* `release` function for backwards-compatibility with existing tests, but you
|
18
|
+
* should use `isOperationRetained` for new tests as it is much less error-prone.
|
19
|
+
*/
|
20
|
+
function trackRetentionForEnvironment(environment) {
|
21
|
+
var retainCountsByOperation = new Map();
|
22
|
+
var release = jest.fn(function (id) {
|
23
|
+
var _retainCountsByOperat;
|
24
|
+
|
25
|
+
var existing = (_retainCountsByOperat = retainCountsByOperation.get(id)) !== null && _retainCountsByOperat !== void 0 ? _retainCountsByOperat : NaN;
|
26
|
+
|
27
|
+
if (existing === 1) {
|
28
|
+
retainCountsByOperation["delete"](id);
|
29
|
+
} else {
|
30
|
+
retainCountsByOperation.set(id, existing - 1);
|
31
|
+
}
|
32
|
+
}); // $FlowFixMe[cannot-write] safe to do for mocking
|
33
|
+
|
34
|
+
environment.retain = jest.fn(function (operation) {
|
35
|
+
var _retainCountsByOperat2;
|
36
|
+
|
37
|
+
var id = operation.request.identifier;
|
38
|
+
var existing = (_retainCountsByOperat2 = retainCountsByOperation.get(id)) !== null && _retainCountsByOperat2 !== void 0 ? _retainCountsByOperat2 : 0;
|
39
|
+
retainCountsByOperation.set(id, existing + 1);
|
40
|
+
var released = false;
|
41
|
+
return {
|
42
|
+
dispose: function dispose() {
|
43
|
+
if (!released) {
|
44
|
+
release(id);
|
45
|
+
}
|
46
|
+
|
47
|
+
released = true;
|
48
|
+
}
|
49
|
+
};
|
50
|
+
});
|
51
|
+
|
52
|
+
function isOperationRetained(operation) {
|
53
|
+
var _retainCountsByOperat3;
|
54
|
+
|
55
|
+
var id = operation.request.identifier;
|
56
|
+
return ((_retainCountsByOperat3 = retainCountsByOperation.get(id)) !== null && _retainCountsByOperat3 !== void 0 ? _retainCountsByOperat3 : 0) > 0;
|
57
|
+
}
|
58
|
+
|
59
|
+
return {
|
60
|
+
release_DEPRECATED: release,
|
61
|
+
isOperationRetained: isOperationRetained
|
62
|
+
};
|
63
|
+
}
|
64
|
+
|
65
|
+
module.exports = trackRetentionForEnvironment;
|
package/lib/warnings.js
CHANGED
@@ -48,8 +48,8 @@ function disallowWarnings() {
|
|
48
48
|
*/
|
49
49
|
|
50
50
|
|
51
|
-
function expectWarningWillFire(message) {
|
52
|
-
warningsSystem.expectMessageWillFire(message);
|
51
|
+
function expectWarningWillFire(message, options) {
|
52
|
+
warningsSystem.expectMessageWillFire(message, options);
|
53
53
|
}
|
54
54
|
/**
|
55
55
|
* Expect the callback `fn` to trigger the warning message and otherwise fail.
|
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": "14.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": "14.0.0"
|
21
21
|
},
|
22
22
|
"directories": {
|
23
23
|
"": "./"
|
@@ -1,4 +1,4 @@
|
|
1
1
|
/**
|
2
|
-
* Relay
|
2
|
+
* Relay v14.0.0
|
3
3
|
*/
|
4
|
-
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,t,n){"use strict";var r=n(0)(n(5)),o=console.error;e.exports={createConsoleInterceptionSystem:function(e,t,n){var c=!1,i=[],a=[],s=e.charAt(0).toUpperCase()+e.slice(1),u=s+"s",l="disallow".concat(s,"s");function f(e){var t=i.findIndex((function(t){return e.startsWith(t)}));if(a.length>0&&a[0]===e)a.shift();else{if(!(t>=0))throw o("Unexpected ".concat(s,": ")+e),new Error("".concat(s,": ")+e);i.splice(t,1)}}function p(n,o){if(a.length>0)throw new Error("Cannot nest ".concat(t,"() calls."));a.push.apply(a,(0,r.default)(n));var c=o();if(a.length>0){var i=a.toString();throw a.length=0,new Error("Expected ".concat(e," in callback: ").concat(i))}return c}return{disallowMessages:function(){if(c)throw new Error("".concat(l," should be called only once."));c=!0,n(f),afterEach((function(){if(a.length=0,i.length>0){var t=new Error("Some expected ".concat(e,"s where not triggered:\n\n")+Array.from(i,(function(e){return" * ".concat(e)})).join("\n")+"\n");throw i.length=0,t}}))},expectMessageWillFire:function(e){if(!c)throw new Error("".concat(l," needs to be called before expect").concat(u,"WillFire"));i.push(e)},expectMessage:function(e,t){return p([e],t)},expectMessageMany:p}}}},function(e,t){e.exports=require("relay-runtime")},function(e,t,n){"use strict";var r=n(4),o=r.disallowConsoleErrors,c=r.expectConsoleError,i=r.expectConsoleErrorsMany,a=r.expectConsoleErrorWillFire,s=n(6),u=n(8),l=u.FIXTURE_TAG,f=u.generateTestsFromFixtures,p=n(13),d=n(15),g=n(17),x=n(18),h=x.disallowWarnings,y=x.expectToWarn,v=x.expectToWarnMany,b=x.expectWarningWillFire,w=n(19),m=w.createMockEnvironment,E=w.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:m,describeWithFeatureFlags:s,disallowConsoleErrors:o,disallowWarnings:h,expectConsoleError:c,expectConsoleErrorsMany:i,expectConsoleErrorWillFire:a,expectToWarn:y,expectToWarnMany:v,expectWarningWillFire:b,FIXTURE_TAG:l,generateTestsFromFixtures:f,matchers:p,printAST:d,simpleClone:g,unwrapContainer:E}},function(e,t,n){"use strict";var r=(0,n(1).createConsoleInterceptionSystem)("error","expectConsoleError",(function(e){jest.spyOn(console,"error").mockImplementation(e)}));e.exports={disallowConsoleErrors:function(){r.disallowMessages()},expectConsoleErrorWillFire:function(e){r.expectMessageWillFire(e)},expectConsoleError:function(e,t){return r.expectMessage(e,t)},expectConsoleErrorsMany:function(e,t){return r.expectMessageMany(e,t)}}},function(e,t){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,t,n){"use strict";var r=n(0)(n(7));e.exports=function(e,t,o){describe.each(e)("".concat(t," - Feature flags: %o"),(function(e){var t;beforeEach((function(){var o=n(2).RelayFeatureFlags;t=(0,r.default)({},o),Object.assign(o,e)})),afterEach((function(){var e=n(2).RelayFeatureFlags;Object.assign(e,t)})),o()}))}},function(e,t){e.exports=require("@babel/runtime/helpers/objectSpread2")},function(e,t,n){"use strict";var r=n(0)(n(9)),o=n(10),c=n(11),i=n(12),a=Symbol.for("FIXTURE_TAG");expect.addSnapshotSerializer({print:function(e){return Object.keys(e).map((function(t){return"~~~~~~~~~~ ".concat(t.toUpperCase()," ~~~~~~~~~~\n").concat(e[t])})).join("\n")},test:function(e){return e&&!0===e[a]}}),e.exports={generateTestsFromFixtures:function(e,t){var n=c.readdirSync(e);test("has fixtures in ".concat(e),(function(){expect(n.length>0).toBe(!0)}));var s=n.filter((function(e){return e.startsWith("only.")}));s.length&&(test.skip.each(n.filter((function(e){return!e.startsWith("only.")})))("matches expected output: %s",(function(){})),n=s),test.each(n)("matches expected output: %s",(function(n){var s,u=c.readFileSync(i.join(e,n),"utf8"),l=o(u,t,n);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,t){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,t,n){"use strict";e.exports=function(e,t,n){if(/^# *expected-to-throw/.test(e)||/\.error\.\w+$/.test(n)){var r;try{r=t(e)}catch(e){return"THROWN EXCEPTION:\n\n".concat(e.toString())}throw new Error("Expected test file '".concat(n,"' to throw, but it passed:\n").concat(r))}return t(e)}},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("path")},function(e,t,n){"use strict";e.exports={toBeDeeplyFrozen:function(e){return function e(t){if(expect(Object.isFrozen(t)).toBe(!0),Array.isArray(t))t.forEach((function(t){return e(t)}));else if("object"==typeof t&&null!==t)for(var n in t)e(t[n])}(e),{pass:!0}},toWarn:function(e,t){var r=this.isNot;function o(e){return e instanceof RegExp?e.toString():JSON.stringify(e)}function c(e){return"["+e.map(o).join(", ")+"]"}function i(e){return e.length?e.map((function(e){return c([!!e[0]].concat(e.slice(1)))})).join(", "):"[]"}var a=n(14);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 t?(Array.isArray(t)||(t=[t]),{pass:!!u.find((function(e){return e.length===t.length+1&&e.every((function(e,n){if(!n)return!e;var r=t[n-1];return r instanceof RegExp?r.test(e):e===r}))})),message:function(){return"Expected ".concat(r?"not ":"","to warn: ")+"".concat(c([!1].concat(t))," but ")+"`warning` received the following calls: "+"".concat(i(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(i(u),".")}}}}},function(e,t){e.exports=require("fbjs/lib/warning")},function(e,t,n){"use strict";var r=n(0)(n(16));e.exports=function(e){return function e(t,n){switch(typeof t){case"undefined":return"undefined";case"object":if(null===t)return"null";if(Array.isArray(t)){if(0===t.length)return"[]";var o,c="[\n",i=n+" ",a=(0,r.default)(t);try{for(a.s();!(o=a.n()).done;){var s=o.value;c+=i+e(s,i)+",\n"}}catch(e){a.e(e)}finally{a.f()}return c+=n+"]"}if("string"==typeof t.kind){for(var u="".concat(t.kind," {\n"),l=n+" ",f=0,p=Object.entries(t);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+=n+"}"}if("function"==typeof t.toJSON)return e(t.toJSON(),n);for(var h="{\n",y=n+" ",v=0,b=Object.entries(t);v<b.length;v++){var w=b[v],m=w[0],E=w[1];h+="".concat(y).concat(JSON.stringify(m),": ").concat(e(E,y),",\n")}return h+=n+"}";case"string":case"number":case"boolean":return JSON.stringify(t,null,2).replace("\n","\n"+n);default:throw new Error("printAST doesn't handle values where "+"typeof value === '".concat(typeof t,"'."))}}(e,"")}},function(e,t){e.exports=require("@babel/runtime/helpers/createForOfIteratorHelper")},function(e,t,n){"use strict";e.exports=function e(t){if(Array.isArray(t))return t.map(e);if(null!=t&&"object"==typeof t){var n={};for(var r in t)n[r]=e(t[r]);return n}return t}},function(e,t,n){"use strict";var r=(0,n(1).createConsoleInterceptionSystem)("warning","expectToWarn",(function(e){jest.mock("fbjs/lib/warning",(function(){return jest.fn((function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),c=2;c<r;c++)o[c-2]=arguments[c];if(!t){var i=0,a=n.replace(/%s/g,(function(){return String(o[i++])}));e(a)}}))}))}));e.exports={disallowWarnings:function(){r.disallowMessages()},expectWarningWillFire:function(e){r.expectMessageWillFire(e)},expectToWarn:function(e,t){return r.expectMessage(e,t)},expectToWarnMany:function(e,t){return r.expectMessageMany(e,t)}}},function(e,t){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=t(0)(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=t(0)(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=t(0)(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=t(0)(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 v14.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 t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,t,n){"use strict";var r=n(0)(n(5)),o=console.error;e.exports={createConsoleInterceptionSystem:function(e,t,n){var c=!1,i=[],a=[],s=e.charAt(0).toUpperCase()+e.slice(1),u=s+"s",l="disallow".concat(s,"s");function f(e){var t=i.findIndex((function(t){return e.startsWith(t)}));if(a.length>0&&a[0]===e)a.shift();else{if(!(t>=0))throw o("Unexpected ".concat(s,": ")+e),new Error("".concat(s,": ")+e);i.splice(t,1)}}function p(n,o){if(a.length>0)throw new Error("Cannot nest ".concat(t,"() calls."));a.push.apply(a,(0,r.default)(n));var c=o();if(a.length>0){var i=a.toString();throw a.length=0,new Error("Expected ".concat(e," in callback: ").concat(i))}return c}return{disallowMessages:function(){if(c)throw new Error("".concat(l," should be called only once."));c=!0,n(f),afterEach((function(){if(a.length=0,i.length>0){var t=new Error("Some expected ".concat(e,"s where not triggered:\n\n")+Array.from(i,(function(e){return" * ".concat(e)})).join("\n")+"\n");throw i.length=0,t}}))},expectMessageWillFire:function(e){if(!c)throw new Error("".concat(l," needs to be called before expect").concat(u,"WillFire"));i.push(e)},expectMessage:function(e,t){return p([e],t)},expectMessageMany:p}}}},function(e,t){e.exports=require("relay-runtime")},function(e,t,n){"use strict";var r=n(4),o=r.disallowConsoleErrors,c=r.expectConsoleError,i=r.expectConsoleErrorsMany,a=r.expectConsoleErrorWillFire,s=n(6),u=n(8),l=u.FIXTURE_TAG,f=u.generateTestsFromFixtures,p=n(13),d=n(15),g=n(17),x=n(18),h=x.disallowWarnings,y=x.expectToWarn,v=x.expectToWarnMany,b=x.expectWarningWillFire,w=n(19),m=w.createMockEnvironment,E=w.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:m,describeWithFeatureFlags:s,disallowConsoleErrors:o,disallowWarnings:h,expectConsoleError:c,expectConsoleErrorsMany:i,expectConsoleErrorWillFire:a,expectToWarn:y,expectToWarnMany:v,expectWarningWillFire:b,FIXTURE_TAG:l,generateTestsFromFixtures:f,matchers:p,printAST:d,simpleClone:g,unwrapContainer:E}},function(e,t,n){"use strict";var r=(0,n(1).createConsoleInterceptionSystem)("error","expectConsoleError",(function(e){jest.spyOn(console,"error").mockImplementation(e)}));e.exports={disallowConsoleErrors:function(){r.disallowMessages()},expectConsoleErrorWillFire:function(e){r.expectMessageWillFire(e)},expectConsoleError:function(e,t){return r.expectMessage(e,t)},expectConsoleErrorsMany:function(e,t){return r.expectMessageMany(e,t)}}},function(e,t){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,t,n){"use strict";var r=n(0)(n(7));e.exports=function(e,t,o){describe.each(e)("".concat(t," - Feature flags: %o"),(function(e){var t;beforeEach((function(){var o=n(2).RelayFeatureFlags;t=(0,r.default)({},o),Object.assign(o,e)})),afterEach((function(){var e=n(2).RelayFeatureFlags;Object.assign(e,t)})),o()}))}},function(e,t){e.exports=require("@babel/runtime/helpers/objectSpread2")},function(e,t,n){"use strict";var r=n(0)(n(9)),o=n(10),c=n(11),i=n(12),a=Symbol.for("FIXTURE_TAG");expect.addSnapshotSerializer({print:function(e){return Object.keys(e).map((function(t){return"~~~~~~~~~~ ".concat(t.toUpperCase()," ~~~~~~~~~~\n").concat(e[t])})).join("\n")},test:function(e){return e&&!0===e[a]}}),e.exports={generateTestsFromFixtures:function(e,t){var n=c.readdirSync(e);test("has fixtures in ".concat(e),(function(){expect(n.length>0).toBe(!0)}));var s=n.filter((function(e){return e.startsWith("only.")}));s.length&&(test.skip.each(n.filter((function(e){return!e.startsWith("only.")})))("matches expected output: %s",(function(){})),n=s),test.each(n)("matches expected output: %s",(function(n){var s,u=c.readFileSync(i.join(e,n),"utf8"),l=o(u,t,n);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,t){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,t,n){"use strict";e.exports=function(e,t,n){if(/^# *expected-to-throw/.test(e)||/\.error\.\w+$/.test(n)){var r;try{r=t(e)}catch(e){return"THROWN EXCEPTION:\n\n".concat(e.toString())}throw new Error("Expected test file '".concat(n,"' to throw, but it passed:\n").concat(r))}return t(e)}},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("path")},function(e,t,n){"use strict";e.exports={toBeDeeplyFrozen:function(e){return function e(t){if(expect(Object.isFrozen(t)).toBe(!0),Array.isArray(t))t.forEach((function(t){return e(t)}));else if("object"==typeof t&&null!==t)for(var n in t)e(t[n])}(e),{pass:!0}},toWarn:function(e,t){var r=this.isNot;function o(e){return e instanceof RegExp?e.toString():JSON.stringify(e)}function c(e){return"["+e.map(o).join(", ")+"]"}function i(e){return e.length?e.map((function(e){return c([!!e[0]].concat(e.slice(1)))})).join(", "):"[]"}var a=n(14);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 t?(Array.isArray(t)||(t=[t]),{pass:!!u.find((function(e){return e.length===t.length+1&&e.every((function(e,n){if(!n)return!e;var r=t[n-1];return r instanceof RegExp?r.test(e):e===r}))})),message:function(){return"Expected ".concat(r?"not ":"","to warn: ")+"".concat(c([!1].concat(t))," but ")+"`warning` received the following calls: "+"".concat(i(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(i(u),".")}}}}},function(e,t){e.exports=require("fbjs/lib/warning")},function(e,t,n){"use strict";var r=n(0)(n(16));e.exports=function(e){return function e(t,n){switch(typeof t){case"undefined":return"undefined";case"object":if(null===t)return"null";if(Array.isArray(t)){if(0===t.length)return"[]";var o,c="[\n",i=n+" ",a=(0,r.default)(t);try{for(a.s();!(o=a.n()).done;){var s=o.value;c+=i+e(s,i)+",\n"}}catch(e){a.e(e)}finally{a.f()}return c+=n+"]"}if("string"==typeof t.kind){for(var u="".concat(t.kind," {\n"),l=n+" ",f=0,p=Object.entries(t);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+=n+"}"}if("function"==typeof t.toJSON)return e(t.toJSON(),n);for(var h="{\n",y=n+" ",v=0,b=Object.entries(t);v<b.length;v++){var w=b[v],m=w[0],E=w[1];h+="".concat(y).concat(JSON.stringify(m),": ").concat(e(E,y),",\n")}return h+=n+"}";case"string":case"number":case"boolean":return JSON.stringify(t,null,2).replace("\n","\n"+n);default:throw new Error("printAST doesn't handle values where "+"typeof value === '".concat(typeof t,"'."))}}(e,"")}},function(e,t){e.exports=require("@babel/runtime/helpers/createForOfIteratorHelper")},function(e,t,n){"use strict";e.exports=function e(t){if(Array.isArray(t))return t.map(e);if(null!=t&&"object"==typeof t){var n={};for(var r in t)n[r]=e(t[r]);return n}return t}},function(e,t,n){"use strict";var r=(0,n(1).createConsoleInterceptionSystem)("warning","expectToWarn",(function(e){jest.mock("fbjs/lib/warning",(function(){return jest.fn((function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),c=2;c<r;c++)o[c-2]=arguments[c];if(!t){var i=0,a=n.replace(/%s/g,(function(){return String(o[i++])}));e(a)}}))}))}));e.exports={disallowWarnings:function(){r.disallowMessages()},expectWarningWillFire:function(e){r.expectMessageWillFire(e)},expectToWarn:function(e,t){return r.expectMessage(e,t)},expectToWarnMany:function(e,t){return r.expectMessageMany(e,t)}}},function(e,t){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=t(0)(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=t(0)(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=t(0)(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=t(0)(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
@@ -22,7 +22,7 @@ function simpleClone<T>(value: T): T {
|
|
22
22
|
// $FlowFixMe[incompatible-return]
|
23
23
|
return value.map(simpleClone);
|
24
24
|
} else if (value != null && typeof value === 'object') {
|
25
|
-
const result = {};
|
25
|
+
const result: {[string]: mixed} = {};
|
26
26
|
for (const key in value) {
|
27
27
|
result[key] = simpleClone(value[key]);
|
28
28
|
}
|
@@ -0,0 +1,65 @@
|
|
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
|
+
* @flow
|
8
|
+
* @format
|
9
|
+
*/
|
10
|
+
|
11
|
+
// flowlint ambiguous-object-type:error
|
12
|
+
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
/* global jest */
|
16
|
+
|
17
|
+
import type {IEnvironment} from '../relay-runtime';
|
18
|
+
import type {OperationDescriptor} from '../relay-runtime/store/RelayStoreTypes';
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Takes an environment and augments it with a mock implementation of `retain`
|
22
|
+
* that tracks what operations are currently retained. Also returns the Jest mock
|
23
|
+
* `release` function for backwards-compatibility with existing tests, but you
|
24
|
+
* should use `isOperationRetained` for new tests as it is much less error-prone.
|
25
|
+
*/
|
26
|
+
function trackRetentionForEnvironment(environment: IEnvironment): {|
|
27
|
+
release_DEPRECATED: JestMockFn<[mixed], void>,
|
28
|
+
isOperationRetained: OperationDescriptor => boolean,
|
29
|
+
|} {
|
30
|
+
const retainCountsByOperation = new Map();
|
31
|
+
|
32
|
+
const release = jest.fn(id => {
|
33
|
+
const existing = retainCountsByOperation.get(id) ?? NaN;
|
34
|
+
if (existing === 1) {
|
35
|
+
retainCountsByOperation.delete(id);
|
36
|
+
} else {
|
37
|
+
retainCountsByOperation.set(id, existing - 1);
|
38
|
+
}
|
39
|
+
});
|
40
|
+
|
41
|
+
// $FlowFixMe[cannot-write] safe to do for mocking
|
42
|
+
environment.retain = jest.fn(operation => {
|
43
|
+
const id = operation.request.identifier;
|
44
|
+
const existing = retainCountsByOperation.get(id) ?? 0;
|
45
|
+
retainCountsByOperation.set(id, existing + 1);
|
46
|
+
let released = false;
|
47
|
+
return {
|
48
|
+
dispose: () => {
|
49
|
+
if (!released) {
|
50
|
+
release(id);
|
51
|
+
}
|
52
|
+
released = true;
|
53
|
+
},
|
54
|
+
};
|
55
|
+
});
|
56
|
+
|
57
|
+
function isOperationRetained(operation: OperationDescriptor) {
|
58
|
+
const id = operation.request.identifier;
|
59
|
+
return (retainCountsByOperation.get(id) ?? 0) > 0;
|
60
|
+
}
|
61
|
+
|
62
|
+
return {release_DEPRECATED: release, isOperationRetained};
|
63
|
+
}
|
64
|
+
|
65
|
+
module.exports = trackRetentionForEnvironment;
|
package/warnings.js.flow
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
|
14
14
|
/* global jest */
|
15
15
|
|
16
|
+
import type {WillFireOptions} from './consoleErrorsAndWarnings';
|
17
|
+
|
16
18
|
const {createConsoleInterceptionSystem} = require('./consoleErrorsAndWarnings');
|
17
19
|
|
18
20
|
const warningsSystem = createConsoleInterceptionSystem(
|
@@ -46,8 +48,11 @@ function disallowWarnings(): void {
|
|
46
48
|
* Expect a warning with the given message. If the message isn't fired in the
|
47
49
|
* current test, the test will fail.
|
48
50
|
*/
|
49
|
-
function expectWarningWillFire(
|
50
|
-
|
51
|
+
function expectWarningWillFire(
|
52
|
+
message: string,
|
53
|
+
options?: WillFireOptions,
|
54
|
+
): void {
|
55
|
+
warningsSystem.expectMessageWillFire(message, options);
|
51
56
|
}
|
52
57
|
|
53
58
|
/**
|