relay-test-utils-internal 13.0.3 → 13.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
+ * @emails oncall+relay
8
+ * @flow strict-local
9
+ * @format
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ /* global jest */
15
+
16
+ const {createConsoleInterceptionSystem} = require('./consoleErrorsAndWarnings');
17
+
18
+ const consoleErrorsSystem = createConsoleInterceptionSystem(
19
+ 'error',
20
+ 'expectConsoleError',
21
+ impl => {
22
+ jest.spyOn(console, 'error').mockImplementation(impl);
23
+ },
24
+ );
25
+
26
+ /**
27
+ * Mocks console.error so that errors printed to the console are instead thrown.
28
+ * Any expected errors need to be explicitly expected with `expectConsoleErrorWillFire(message)`.
29
+ *
30
+ * NOTE: This should be called on top of a test file. The test should NOT
31
+ * use `jest.resetModules()` or manually mock `console`.
32
+ */
33
+ function disallowConsoleErrors(): void {
34
+ consoleErrorsSystem.disallowMessages();
35
+ }
36
+
37
+ /**
38
+ * Expect an error with the given message. If the message isn't fired in the
39
+ * current test, the test will fail.
40
+ */
41
+ function expectConsoleErrorWillFire(message: string): void {
42
+ consoleErrorsSystem.expectMessageWillFire(message);
43
+ }
44
+
45
+ /**
46
+ * Expect the callback `fn` to print an error with the message, and otherwise fail.
47
+ */
48
+ function expectConsoleError<T>(message: string, fn: () => T): T {
49
+ return consoleErrorsSystem.expectMessage(message, fn);
50
+ }
51
+
52
+ /**
53
+ * Expect the callback `fn` to trigger all console errors (in sequence),
54
+ * and otherwise fail.
55
+ */
56
+ function expectConsoleErrorsMany<T>(messages: Array<string>, fn: () => T): T {
57
+ return consoleErrorsSystem.expectMessageMany(messages, fn);
58
+ }
59
+
60
+ module.exports = {
61
+ disallowConsoleErrors,
62
+ expectConsoleErrorWillFire,
63
+ expectConsoleError,
64
+ expectConsoleErrorsMany,
65
+ };
@@ -0,0 +1,116 @@
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, afterEach */
15
+
16
+ type API = $ReadOnly<{|
17
+ disallowMessages: () => void,
18
+ expectMessageWillFire: string => void,
19
+ expectMessage: <T>(string, () => T) => T,
20
+ expectMessageMany: <T>(Array<string>, () => T) => T,
21
+ |}>;
22
+
23
+ const originalConsoleError = console.error;
24
+
25
+ function createConsoleInterceptionSystem(
26
+ typename: string,
27
+ expectFunctionName: string,
28
+ setUpMock: ((string) => void) => void,
29
+ ): API {
30
+ let installed = false;
31
+ const expectedMessages: Array<string> = [];
32
+ const contextualExpectedMessage: Array<string> = [];
33
+
34
+ const typenameCap = typename.charAt(0).toUpperCase() + typename.slice(1);
35
+ const typenameCapPlural = typenameCap + 's';
36
+ const installerName = `disallow${typenameCap}s`;
37
+
38
+ function handleMessage(message: string): void {
39
+ const index = expectedMessages.findIndex(expected =>
40
+ message.startsWith(expected),
41
+ );
42
+ if (
43
+ contextualExpectedMessage.length > 0 &&
44
+ contextualExpectedMessage[0] === message
45
+ ) {
46
+ contextualExpectedMessage.shift();
47
+ } else if (index >= 0) {
48
+ expectedMessages.splice(index, 1);
49
+ } else {
50
+ // log to console in case the error gets swallowed somewhere
51
+ originalConsoleError(`Unexpected ${typenameCap}: ` + message);
52
+ throw new Error(`${typenameCap}: ` + message);
53
+ }
54
+ }
55
+
56
+ function disallowMessages(): void {
57
+ if (installed) {
58
+ throw new Error(`${installerName} should be called only once.`);
59
+ }
60
+ installed = true;
61
+ setUpMock(handleMessage);
62
+
63
+ afterEach(() => {
64
+ contextualExpectedMessage.length = 0;
65
+ if (expectedMessages.length > 0) {
66
+ const error = new Error(
67
+ `Some expected ${typename}s where not triggered:\n\n` +
68
+ Array.from(expectedMessages, message => ` * ${message}`).join(
69
+ '\n',
70
+ ) +
71
+ '\n',
72
+ );
73
+ expectedMessages.length = 0;
74
+ throw error;
75
+ }
76
+ });
77
+ }
78
+
79
+ function expectMessageWillFire(message: string): void {
80
+ if (!installed) {
81
+ throw new Error(
82
+ `${installerName} needs to be called before expect${typenameCapPlural}WillFire`,
83
+ );
84
+ }
85
+ expectedMessages.push(message);
86
+ }
87
+
88
+ function expectMessage<T>(message: string, fn: () => T): T {
89
+ return expectMessageMany([message], fn);
90
+ }
91
+
92
+ function expectMessageMany<T>(messages: Array<string>, fn: () => T): T {
93
+ if (contextualExpectedMessage.length > 0) {
94
+ throw new Error(`Cannot nest ${expectFunctionName}() calls.`);
95
+ }
96
+ contextualExpectedMessage.push(...messages);
97
+ const result = fn();
98
+ if (contextualExpectedMessage.length > 0) {
99
+ const notFired = contextualExpectedMessage.toString();
100
+ contextualExpectedMessage.length = 0;
101
+ throw new Error(`Expected ${typename} in callback: ${notFired}`);
102
+ }
103
+ return result;
104
+ }
105
+
106
+ return {
107
+ disallowMessages,
108
+ expectMessageWillFire,
109
+ expectMessage,
110
+ expectMessageMany,
111
+ };
112
+ }
113
+
114
+ module.exports = {
115
+ createConsoleInterceptionSystem,
116
+ };
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v13.0.3
2
+ * Relay v13.2.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.js.flow CHANGED
@@ -12,6 +12,12 @@
12
12
 
13
13
  'use strict';
14
14
 
15
+ const {
16
+ disallowConsoleErrors,
17
+ expectConsoleError,
18
+ expectConsoleErrorsMany,
19
+ expectConsoleErrorWillFire,
20
+ } = require('./consoleError');
15
21
  const describeWithFeatureFlags = require('./describeWithFeatureFlags');
16
22
  const {
17
23
  FIXTURE_TAG,
@@ -50,10 +56,14 @@ module.exports = {
50
56
  cannotReadPropertyOfUndefined__DEPRECATED,
51
57
  createMockEnvironment,
52
58
  describeWithFeatureFlags,
59
+ disallowConsoleErrors,
60
+ disallowWarnings,
61
+ expectConsoleError,
62
+ expectConsoleErrorsMany,
63
+ expectConsoleErrorWillFire,
53
64
  expectToWarn,
54
65
  expectToWarnMany,
55
66
  expectWarningWillFire,
56
- disallowWarnings,
57
67
  FIXTURE_TAG,
58
68
  generateTestsFromFixtures,
59
69
  matchers: Matchers,
@@ -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 consoleErrorsSystem = createConsoleInterceptionSystem('error', 'expectConsoleError', function (impl) {
18
+ jest.spyOn(console, 'error').mockImplementation(impl);
19
+ });
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
+ function disallowConsoleErrors() {
29
+ consoleErrorsSystem.disallowMessages();
30
+ }
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
+ function expectConsoleErrorWillFire(message) {
38
+ consoleErrorsSystem.expectMessageWillFire(message);
39
+ }
40
+ /**
41
+ * Expect the callback `fn` to print an error with the message, and otherwise fail.
42
+ */
43
+
44
+
45
+ function expectConsoleError(message, fn) {
46
+ return consoleErrorsSystem.expectMessage(message, fn);
47
+ }
48
+ /**
49
+ * Expect the callback `fn` to trigger all console errors (in sequence),
50
+ * and otherwise fail.
51
+ */
52
+
53
+
54
+ function expectConsoleErrorsMany(messages, fn) {
55
+ return consoleErrorsSystem.expectMessageMany(messages, fn);
56
+ }
57
+
58
+ module.exports = {
59
+ disallowConsoleErrors: disallowConsoleErrors,
60
+ expectConsoleErrorWillFire: expectConsoleErrorWillFire,
61
+ expectConsoleError: expectConsoleError,
62
+ expectConsoleErrorsMany: expectConsoleErrorsMany
63
+ };
@@ -0,0 +1,103 @@
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, afterEach */
13
+
14
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
15
+
16
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
+
18
+ var originalConsoleError = console.error;
19
+
20
+ function createConsoleInterceptionSystem(typename, expectFunctionName, setUpMock) {
21
+ var installed = false;
22
+ var expectedMessages = [];
23
+ var contextualExpectedMessage = [];
24
+ var typenameCap = typename.charAt(0).toUpperCase() + typename.slice(1);
25
+ var typenameCapPlural = typenameCap + 's';
26
+ var installerName = "disallow".concat(typenameCap, "s");
27
+
28
+ function handleMessage(message) {
29
+ var index = expectedMessages.findIndex(function (expected) {
30
+ return message.startsWith(expected);
31
+ });
32
+
33
+ if (contextualExpectedMessage.length > 0 && contextualExpectedMessage[0] === message) {
34
+ contextualExpectedMessage.shift();
35
+ } else if (index >= 0) {
36
+ expectedMessages.splice(index, 1);
37
+ } else {
38
+ // log to console in case the error gets swallowed somewhere
39
+ originalConsoleError("Unexpected ".concat(typenameCap, ": ") + message);
40
+ throw new Error("".concat(typenameCap, ": ") + message);
41
+ }
42
+ }
43
+
44
+ function disallowMessages() {
45
+ if (installed) {
46
+ throw new Error("".concat(installerName, " should be called only once."));
47
+ }
48
+
49
+ installed = true;
50
+ setUpMock(handleMessage);
51
+ afterEach(function () {
52
+ contextualExpectedMessage.length = 0;
53
+
54
+ if (expectedMessages.length > 0) {
55
+ var error = new Error("Some expected ".concat(typename, "s where not triggered:\n\n") + Array.from(expectedMessages, function (message) {
56
+ return " * ".concat(message);
57
+ }).join('\n') + '\n');
58
+ expectedMessages.length = 0;
59
+ throw error;
60
+ }
61
+ });
62
+ }
63
+
64
+ function expectMessageWillFire(message) {
65
+ if (!installed) {
66
+ throw new Error("".concat(installerName, " needs to be called before expect").concat(typenameCapPlural, "WillFire"));
67
+ }
68
+
69
+ expectedMessages.push(message);
70
+ }
71
+
72
+ function expectMessage(message, fn) {
73
+ return expectMessageMany([message], fn);
74
+ }
75
+
76
+ function expectMessageMany(messages, fn) {
77
+ if (contextualExpectedMessage.length > 0) {
78
+ throw new Error("Cannot nest ".concat(expectFunctionName, "() calls."));
79
+ }
80
+
81
+ contextualExpectedMessage.push.apply(contextualExpectedMessage, (0, _toConsumableArray2["default"])(messages));
82
+ var result = fn();
83
+
84
+ if (contextualExpectedMessage.length > 0) {
85
+ var notFired = contextualExpectedMessage.toString();
86
+ contextualExpectedMessage.length = 0;
87
+ throw new Error("Expected ".concat(typename, " in callback: ").concat(notFired));
88
+ }
89
+
90
+ return result;
91
+ }
92
+
93
+ return {
94
+ disallowMessages: disallowMessages,
95
+ expectMessageWillFire: expectMessageWillFire,
96
+ expectMessage: expectMessage,
97
+ expectMessageMany: expectMessageMany
98
+ };
99
+ }
100
+
101
+ module.exports = {
102
+ createConsoleInterceptionSystem: createConsoleInterceptionSystem
103
+ };
package/lib/index.js CHANGED
@@ -10,11 +10,17 @@
10
10
  // flowlint ambiguous-object-type:error
11
11
  'use strict';
12
12
 
13
+ var _require = require('./consoleError'),
14
+ disallowConsoleErrors = _require.disallowConsoleErrors,
15
+ expectConsoleError = _require.expectConsoleError,
16
+ expectConsoleErrorsMany = _require.expectConsoleErrorsMany,
17
+ expectConsoleErrorWillFire = _require.expectConsoleErrorWillFire;
18
+
13
19
  var describeWithFeatureFlags = require('./describeWithFeatureFlags');
14
20
 
15
- var _require = require('./generateTestsFromFixtures'),
16
- FIXTURE_TAG = _require.FIXTURE_TAG,
17
- generateTestsFromFixtures = _require.generateTestsFromFixtures;
21
+ var _require2 = require('./generateTestsFromFixtures'),
22
+ FIXTURE_TAG = _require2.FIXTURE_TAG,
23
+ generateTestsFromFixtures = _require2.generateTestsFromFixtures;
18
24
 
19
25
  var Matchers = require('./Matchers');
20
26
 
@@ -22,15 +28,15 @@ var printAST = require('./printAST');
22
28
 
23
29
  var simpleClone = require('./simpleClone');
24
30
 
25
- var _require2 = require('./warnings'),
26
- disallowWarnings = _require2.disallowWarnings,
27
- expectToWarn = _require2.expectToWarn,
28
- expectToWarnMany = _require2.expectToWarnMany,
29
- expectWarningWillFire = _require2.expectWarningWillFire;
31
+ var _require3 = require('./warnings'),
32
+ disallowWarnings = _require3.disallowWarnings,
33
+ expectToWarn = _require3.expectToWarn,
34
+ expectToWarnMany = _require3.expectToWarnMany,
35
+ expectWarningWillFire = _require3.expectWarningWillFire;
30
36
 
31
- var _require3 = require('relay-test-utils'),
32
- createMockEnvironment = _require3.createMockEnvironment,
33
- unwrapContainer = _require3.unwrapContainer; // Apparently, in node v16 (because now they are using V8 V9.something)
37
+ var _require4 = require('relay-test-utils'),
38
+ createMockEnvironment = _require4.createMockEnvironment,
39
+ unwrapContainer = _require4.unwrapContainer; // Apparently, in node v16 (because now they are using V8 V9.something)
34
40
  // the content of the TypeError has changed, and now some of our tests
35
41
  // stated to fail.
36
42
  // This is a temporary work-around to make test pass, but we need to
@@ -53,10 +59,14 @@ module.exports = {
53
59
  cannotReadPropertyOfUndefined__DEPRECATED: cannotReadPropertyOfUndefined__DEPRECATED,
54
60
  createMockEnvironment: createMockEnvironment,
55
61
  describeWithFeatureFlags: describeWithFeatureFlags,
62
+ disallowConsoleErrors: disallowConsoleErrors,
63
+ disallowWarnings: disallowWarnings,
64
+ expectConsoleError: expectConsoleError,
65
+ expectConsoleErrorsMany: expectConsoleErrorsMany,
66
+ expectConsoleErrorWillFire: expectConsoleErrorWillFire,
56
67
  expectToWarn: expectToWarn,
57
68
  expectToWarnMany: expectToWarnMany,
58
69
  expectWarningWillFire: expectWarningWillFire,
59
- disallowWarnings: disallowWarnings,
60
70
  FIXTURE_TAG: FIXTURE_TAG,
61
71
  generateTestsFromFixtures: generateTestsFromFixtures,
62
72
  matchers: Matchers,
package/lib/warnings.js CHANGED
@@ -9,29 +9,12 @@
9
9
  * @format
10
10
  */
11
11
  'use strict';
12
- /* global jest, afterEach */
12
+ /* global jest */
13
13
 
14
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
14
+ var _require = require('./consoleErrorsAndWarnings'),
15
+ createConsoleInterceptionSystem = _require.createConsoleInterceptionSystem;
15
16
 
16
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
-
18
- var installed = false;
19
- var expectedWarnings = [];
20
- var contextualExpectedWarning = [];
21
- /**
22
- * Mocks the `warning` module to turn warnings into errors. Any expected
23
- * warnings need to be explicitly expected with `expectWarningWillFire(message)`.
24
- *
25
- * NOTE: This should be called on top of a test file. The test should NOT
26
- * use `jest.resetModules()` or manually mock `warning`.
27
- */
28
-
29
- function disallowWarnings() {
30
- if (installed) {
31
- throw new Error('`disallowWarnings` should be called at most once');
32
- }
33
-
34
- installed = true;
17
+ var warningsSystem = createConsoleInterceptionSystem('warning', 'expectToWarn', function (impl) {
35
18
  jest.mock("fbjs/lib/warning", function () {
36
19
  return jest.fn(function (condition, format) {
37
20
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
@@ -43,31 +26,21 @@ function disallowWarnings() {
43
26
  var message = format.replace(/%s/g, function () {
44
27
  return String(args[argIndex++]);
45
28
  });
46
- var index = expectedWarnings.indexOf(message);
47
-
48
- if (contextualExpectedWarning.length > 0 && contextualExpectedWarning[0] === message) {
49
- contextualExpectedWarning.shift();
50
- } else if (index >= 0) {
51
- expectedWarnings.splice(index, 1);
52
- } else {
53
- // log to console in case the error gets swallowed somewhere
54
- console.error('Unexpected Warning: ' + message);
55
- throw new Error('Warning: ' + message);
56
- }
29
+ impl(message);
57
30
  }
58
31
  });
59
32
  });
60
- afterEach(function () {
61
- contextualExpectedWarning.length = 0;
33
+ });
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
+ */
62
41
 
63
- if (expectedWarnings.length > 0) {
64
- var error = new Error('Some expected warnings where not triggered:\n\n' + Array.from(expectedWarnings, function (message) {
65
- return " * ".concat(message);
66
- }).join('\n') + '\n');
67
- expectedWarnings.length = 0;
68
- throw error;
69
- }
70
- });
42
+ function disallowWarnings() {
43
+ warningsSystem.disallowMessages();
71
44
  }
72
45
  /**
73
46
  * Expect a warning with the given message. If the message isn't fired in the
@@ -76,11 +49,7 @@ function disallowWarnings() {
76
49
 
77
50
 
78
51
  function expectWarningWillFire(message) {
79
- if (!installed) {
80
- throw new Error('`disallowWarnings` needs to be called before `expectWarningWillFire`');
81
- }
82
-
83
- expectedWarnings.push(message);
52
+ warningsSystem.expectMessageWillFire(message);
84
53
  }
85
54
  /**
86
55
  * Expect the callback `fn` to trigger the warning message and otherwise fail.
@@ -88,7 +57,7 @@ function expectWarningWillFire(message) {
88
57
 
89
58
 
90
59
  function expectToWarn(message, fn) {
91
- return expectToWarnMany([message], fn);
60
+ return warningsSystem.expectMessage(message, fn);
92
61
  }
93
62
  /**
94
63
  * Expect the callback `fn` to trigger all warning messages (in sequence)
@@ -97,20 +66,7 @@ function expectToWarn(message, fn) {
97
66
 
98
67
 
99
68
  function expectToWarnMany(messages, fn) {
100
- if (contextualExpectedWarning.length > 0) {
101
- throw new Error('Cannot nest `expectToWarn()` calls.');
102
- }
103
-
104
- contextualExpectedWarning.push.apply(contextualExpectedWarning, (0, _toConsumableArray2["default"])(messages));
105
- var result = fn();
106
-
107
- if (contextualExpectedWarning.length > 0) {
108
- var notFired = contextualExpectedWarning.toString();
109
- contextualExpectedWarning.length = 0;
110
- throw new Error("Expected callback to warn: ".concat(notFired));
111
- }
112
-
113
- return result;
69
+ return warningsSystem.expectMessageMany(messages, fn);
114
70
  }
115
71
 
116
72
  module.exports = {
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": "13.0.3",
4
+ "version": "13.2.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": "13.0.3"
20
+ "relay-runtime": "13.2.0"
21
21
  },
22
22
  "directories": {
23
23
  "": "./"
@@ -1,4 +1,4 @@
1
1
  /**
2
- * Relay v13.0.3
2
+ * Relay v13.2.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=2)}([function(e,n){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,n){e.exports=require("relay-runtime")},function(e,n,t){"use strict";var r=t(3),o=t(5),i=o.FIXTURE_TAG,a=o.generateTestsFromFixtures,c=t(10),u=t(12),s=t(14),f=t(15),l=f.disallowWarnings,p=f.expectToWarn,d=f.expectToWarnMany,g=f.expectWarningWillFire,h=t(17),x=h.createMockEnvironment,y=h.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:x,describeWithFeatureFlags:r,expectToWarn:p,expectToWarnMany:d,expectWarningWillFire:g,disallowWarnings:l,FIXTURE_TAG:i,generateTestsFromFixtures:a,matchers:c,printAST:u,simpleClone:s,unwrapContainer:y}},function(e,n,t){"use strict";var r=t(0)(t(4));e.exports=function(e,n,o){describe.each(e)("".concat(n," - Feature flags: %o"),(function(e){var n;beforeEach((function(){var o=t(1).RelayFeatureFlags;n=(0,r.default)({},o),Object.assign(o,e)})),afterEach((function(){var e=t(1).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(6)),o=t(7),i=t(8),a=t(9),c=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[c]}}),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 u=t.filter((function(e){return e.startsWith("only.")}));u.length&&(test.skip.each(t.filter((function(e){return!e.startsWith("only.")})))("matches expected output: %s",(function(){})),t=u),test.each(t)("matches expected output: %s",(function(t){var u,s=i.readFileSync(a.join(e,t),"utf8"),f=o(s,n,t);expect((u={},(0,r.default)(u,c,!0),(0,r.default)(u,"input",s),(0,r.default)(u,"output",f),u)).toMatchSnapshot()}))},FIXTURE_TAG:c}},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 a(e){return e.length?e.map((function(e){return i([!!e[0]].concat(e.slice(1)))})).join(", "):"[]"}var c=t(11);if(!c.mock)throw new Error("toWarn(): Requires `jest.mock('warning')`.");var u=c.mock.calls.length;e();var s=c.mock.calls.slice(u);return n?(Array.isArray(n)||(n=[n]),{pass:!!s.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(a(s),".")}}):{pass:!!s.filter((function(e){return!e[0]})).length,message:function(){return"Expected ".concat(r?"not ":"","to warn but ")+"`warning` received the following calls: "+"".concat(a(s),".")}}}}},function(e,n){e.exports=require("fbjs/lib/warning")},function(e,n,t){"use strict";var r=t(0)(t(13));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",a=t+" ",c=(0,r.default)(n);try{for(c.s();!(o=c.n()).done;){var u=o.value;i+=a+e(u,a)+",\n"}}catch(e){c.e(e)}finally{c.f()}return i+=t+"]"}if("string"==typeof n.kind){for(var s="".concat(n.kind," {\n"),f=t+" ",l=0,p=Object.entries(n);l<p.length;l++){var d=p[l],g=d[0],h=d[1];"kind"!==g&&(s+="".concat(f).concat(g,": ").concat(e(h,f),",\n"))}return s+=t+"}"}if("function"==typeof n.toJSON)return e(n.toJSON(),t);for(var x="{\n",y=t+" ",b=0,v=Object.entries(n);b<v.length;b++){var w=v[b],m=w[0],E=w[1];x+="".concat(y).concat(JSON.stringify(m),": ").concat(e(E,y),",\n")}return x+=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";var r=t(0)(t(16)),o=!1,i=[],a=[];function c(e,n){if(a.length>0)throw new Error("Cannot nest `expectToWarn()` calls.");a.push.apply(a,(0,r.default)(e));var t=n();if(a.length>0){var o=a.toString();throw a.length=0,new Error("Expected callback to warn: ".concat(o))}return t}e.exports={disallowWarnings:function(){if(o)throw new Error("`disallowWarnings` should be called at most once");o=!0,jest.mock("fbjs/lib/warning",(function(){return jest.fn((function(e,n){for(var t=arguments.length,r=new Array(t>2?t-2:0),o=2;o<t;o++)r[o-2]=arguments[o];if(!e){var c=0,u=n.replace(/%s/g,(function(){return String(r[c++])})),s=i.indexOf(u);if(a.length>0&&a[0]===u)a.shift();else{if(!(s>=0))throw console.error("Unexpected Warning: "+u),new Error("Warning: "+u);i.splice(s,1)}}}))})),afterEach((function(){if(a.length=0,i.length>0){var e=new Error("Some expected warnings where not triggered:\n\n"+Array.from(i,(function(e){return" * ".concat(e)})).join("\n")+"\n");throw i.length=0,e}}))},expectWarningWillFire:function(e){if(!o)throw new Error("`disallowWarnings` needs to be called before `expectWarningWillFire`");i.push(e)},expectToWarn:function(e,n){return c([e],n)},expectToWarnMany:c}},function(e,n){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,n){e.exports=require("relay-test-utils")}]);
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")}]);
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Relay v13.0.3
2
+ * Relay v13.2.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=2)}([function(e,n){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,n){e.exports=require("relay-runtime")},function(e,n,t){"use strict";var r=t(3),o=t(5),i=o.FIXTURE_TAG,a=o.generateTestsFromFixtures,c=t(10),u=t(12),s=t(14),f=t(15),l=f.disallowWarnings,p=f.expectToWarn,d=f.expectToWarnMany,g=f.expectWarningWillFire,h=t(17),x=h.createMockEnvironment,y=h.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:x,describeWithFeatureFlags:r,expectToWarn:p,expectToWarnMany:d,expectWarningWillFire:g,disallowWarnings:l,FIXTURE_TAG:i,generateTestsFromFixtures:a,matchers:c,printAST:u,simpleClone:s,unwrapContainer:y}},function(e,n,t){"use strict";var r=t(0)(t(4));e.exports=function(e,n,o){describe.each(e)("".concat(n," - Feature flags: %o"),(function(e){var n;beforeEach((function(){var o=t(1).RelayFeatureFlags;n=(0,r.default)({},o),Object.assign(o,e)})),afterEach((function(){var e=t(1).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(6)),o=t(7),i=t(8),a=t(9),c=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[c]}}),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 u=t.filter((function(e){return e.startsWith("only.")}));u.length&&(test.skip.each(t.filter((function(e){return!e.startsWith("only.")})))("matches expected output: %s",(function(){})),t=u),test.each(t)("matches expected output: %s",(function(t){var u,s=i.readFileSync(a.join(e,t),"utf8"),f=o(s,n,t);expect((u={},(0,r.default)(u,c,!0),(0,r.default)(u,"input",s),(0,r.default)(u,"output",f),u)).toMatchSnapshot()}))},FIXTURE_TAG:c}},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 a(e){return e.length?e.map((function(e){return i([!!e[0]].concat(e.slice(1)))})).join(", "):"[]"}var c=t(11);if(!c.mock)throw new Error("toWarn(): Requires `jest.mock('warning')`.");var u=c.mock.calls.length;e();var s=c.mock.calls.slice(u);return n?(Array.isArray(n)||(n=[n]),{pass:!!s.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(a(s),".")}}):{pass:!!s.filter((function(e){return!e[0]})).length,message:function(){return"Expected ".concat(r?"not ":"","to warn but ")+"`warning` received the following calls: "+"".concat(a(s),".")}}}}},function(e,n){e.exports=require("fbjs/lib/warning")},function(e,n,t){"use strict";var r=t(0)(t(13));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",a=t+" ",c=(0,r.default)(n);try{for(c.s();!(o=c.n()).done;){var u=o.value;i+=a+e(u,a)+",\n"}}catch(e){c.e(e)}finally{c.f()}return i+=t+"]"}if("string"==typeof n.kind){for(var s="".concat(n.kind," {\n"),f=t+" ",l=0,p=Object.entries(n);l<p.length;l++){var d=p[l],g=d[0],h=d[1];"kind"!==g&&(s+="".concat(f).concat(g,": ").concat(e(h,f),",\n"))}return s+=t+"}"}if("function"==typeof n.toJSON)return e(n.toJSON(),t);for(var x="{\n",y=t+" ",b=0,v=Object.entries(n);b<v.length;b++){var w=v[b],m=w[0],E=w[1];x+="".concat(y).concat(JSON.stringify(m),": ").concat(e(E,y),",\n")}return x+=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";var r=t(0)(t(16)),o=!1,i=[],a=[];function c(e,n){if(a.length>0)throw new Error("Cannot nest `expectToWarn()` calls.");a.push.apply(a,(0,r.default)(e));var t=n();if(a.length>0){var o=a.toString();throw a.length=0,new Error("Expected callback to warn: ".concat(o))}return t}e.exports={disallowWarnings:function(){if(o)throw new Error("`disallowWarnings` should be called at most once");o=!0,jest.mock("fbjs/lib/warning",(function(){return jest.fn((function(e,n){for(var t=arguments.length,r=new Array(t>2?t-2:0),o=2;o<t;o++)r[o-2]=arguments[o];if(!e){var c=0,u=n.replace(/%s/g,(function(){return String(r[c++])})),s=i.indexOf(u);if(a.length>0&&a[0]===u)a.shift();else{if(!(s>=0))throw console.error("Unexpected Warning: "+u),new Error("Warning: "+u);i.splice(s,1)}}}))})),afterEach((function(){if(a.length=0,i.length>0){var e=new Error("Some expected warnings where not triggered:\n\n"+Array.from(i,(function(e){return" * ".concat(e)})).join("\n")+"\n");throw i.length=0,e}}))},expectWarningWillFire:function(e){if(!o)throw new Error("`disallowWarnings` needs to be called before `expectWarningWillFire`");i.push(e)},expectToWarn:function(e,n){return c([e],n)},expectToWarnMany:c}},function(e,n){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,n){e.exports=require("relay-test-utils")}]);
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")}]);
package/warnings.js.flow CHANGED
@@ -11,11 +11,25 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- /* global jest, afterEach */
14
+ /* global jest */
15
15
 
16
- let installed = false;
17
- const expectedWarnings: Array<string> = [];
18
- const contextualExpectedWarning: Array<string> = [];
16
+ const {createConsoleInterceptionSystem} = require('./consoleErrorsAndWarnings');
17
+
18
+ const warningsSystem = createConsoleInterceptionSystem(
19
+ 'warning',
20
+ 'expectToWarn',
21
+ impl => {
22
+ jest.mock('warning', () =>
23
+ jest.fn((condition, format, ...args) => {
24
+ if (!condition) {
25
+ let argIndex = 0;
26
+ const message = format.replace(/%s/g, () => String(args[argIndex++]));
27
+ impl(message);
28
+ }
29
+ }),
30
+ );
31
+ },
32
+ );
19
33
 
20
34
  /**
21
35
  * Mocks the `warning` module to turn warnings into errors. Any expected
@@ -25,44 +39,7 @@ const contextualExpectedWarning: Array<string> = [];
25
39
  * use `jest.resetModules()` or manually mock `warning`.
26
40
  */
27
41
  function disallowWarnings(): void {
28
- if (installed) {
29
- throw new Error('`disallowWarnings` should be called at most once');
30
- }
31
- installed = true;
32
- jest.mock('warning', () => {
33
- return jest.fn((condition, format, ...args) => {
34
- if (!condition) {
35
- let argIndex = 0;
36
- const message = format.replace(/%s/g, () => String(args[argIndex++]));
37
- const index = expectedWarnings.indexOf(message);
38
-
39
- if (
40
- contextualExpectedWarning.length > 0 &&
41
- contextualExpectedWarning[0] === message
42
- ) {
43
- contextualExpectedWarning.shift();
44
- } else if (index >= 0) {
45
- expectedWarnings.splice(index, 1);
46
- } else {
47
- // log to console in case the error gets swallowed somewhere
48
- console.error('Unexpected Warning: ' + message);
49
- throw new Error('Warning: ' + message);
50
- }
51
- }
52
- });
53
- });
54
- afterEach(() => {
55
- contextualExpectedWarning.length = 0;
56
- if (expectedWarnings.length > 0) {
57
- const error = new Error(
58
- 'Some expected warnings where not triggered:\n\n' +
59
- Array.from(expectedWarnings, message => ` * ${message}`).join('\n') +
60
- '\n',
61
- );
62
- expectedWarnings.length = 0;
63
- throw error;
64
- }
65
- });
42
+ warningsSystem.disallowMessages();
66
43
  }
67
44
 
68
45
  /**
@@ -70,19 +47,14 @@ function disallowWarnings(): void {
70
47
  * current test, the test will fail.
71
48
  */
72
49
  function expectWarningWillFire(message: string): void {
73
- if (!installed) {
74
- throw new Error(
75
- '`disallowWarnings` needs to be called before `expectWarningWillFire`',
76
- );
77
- }
78
- expectedWarnings.push(message);
50
+ warningsSystem.expectMessageWillFire(message);
79
51
  }
80
52
 
81
53
  /**
82
54
  * Expect the callback `fn` to trigger the warning message and otherwise fail.
83
55
  */
84
56
  function expectToWarn<T>(message: string, fn: () => T): T {
85
- return expectToWarnMany([message], fn);
57
+ return warningsSystem.expectMessage(message, fn);
86
58
  }
87
59
 
88
60
  /**
@@ -90,17 +62,7 @@ function expectToWarn<T>(message: string, fn: () => T): T {
90
62
  * or otherwise fail.
91
63
  */
92
64
  function expectToWarnMany<T>(messages: Array<string>, fn: () => T): T {
93
- if (contextualExpectedWarning.length > 0) {
94
- throw new Error('Cannot nest `expectToWarn()` calls.');
95
- }
96
- contextualExpectedWarning.push(...messages);
97
- const result = fn();
98
- if (contextualExpectedWarning.length > 0) {
99
- const notFired = contextualExpectedWarning.toString();
100
- contextualExpectedWarning.length = 0;
101
- throw new Error(`Expected callback to warn: ${notFired}`);
102
- }
103
- return result;
65
+ return warningsSystem.expectMessageMany(messages, fn);
104
66
  }
105
67
 
106
68
  module.exports = {