relay-test-utils-internal 13.0.1 → 13.1.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,4 +1,3 @@
1
- relay-test-utils-internal
2
- ---
1
+ ## relay-test-utils-internal
3
2
 
4
3
  A collection of internal helpers used for relay unit-tests.
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v13.0.1
2
+ * Relay v13.1.1
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.js.flow CHANGED
@@ -23,6 +23,7 @@ const simpleClone = require('./simpleClone');
23
23
  const {
24
24
  disallowWarnings,
25
25
  expectToWarn,
26
+ expectToWarnMany,
26
27
  expectWarningWillFire,
27
28
  } = require('./warnings');
28
29
  const {createMockEnvironment, unwrapContainer} = require('relay-test-utils');
@@ -50,6 +51,7 @@ module.exports = {
50
51
  createMockEnvironment,
51
52
  describeWithFeatureFlags,
52
53
  expectToWarn,
54
+ expectToWarnMany,
53
55
  expectWarningWillFire,
54
56
  disallowWarnings,
55
57
  FIXTURE_TAG,
package/lib/index.js CHANGED
@@ -25,6 +25,7 @@ var simpleClone = require('./simpleClone');
25
25
  var _require2 = require('./warnings'),
26
26
  disallowWarnings = _require2.disallowWarnings,
27
27
  expectToWarn = _require2.expectToWarn,
28
+ expectToWarnMany = _require2.expectToWarnMany,
28
29
  expectWarningWillFire = _require2.expectWarningWillFire;
29
30
 
30
31
  var _require3 = require('relay-test-utils'),
@@ -53,6 +54,7 @@ module.exports = {
53
54
  createMockEnvironment: createMockEnvironment,
54
55
  describeWithFeatureFlags: describeWithFeatureFlags,
55
56
  expectToWarn: expectToWarn,
57
+ expectToWarnMany: expectToWarnMany,
56
58
  expectWarningWillFire: expectWarningWillFire,
57
59
  disallowWarnings: disallowWarnings,
58
60
  FIXTURE_TAG: FIXTURE_TAG,
package/lib/warnings.js CHANGED
@@ -11,9 +11,13 @@
11
11
  'use strict';
12
12
  /* global jest, afterEach */
13
13
 
14
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
15
+
16
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
+
14
18
  var installed = false;
15
19
  var expectedWarnings = [];
16
- var contextualExpectedWarning = null;
20
+ var contextualExpectedWarning = [];
17
21
  /**
18
22
  * Mocks the `warning` module to turn warnings into errors. Any expected
19
23
  * warnings need to be explicitly expected with `expectWarningWillFire(message)`.
@@ -41,8 +45,8 @@ function disallowWarnings() {
41
45
  });
42
46
  var index = expectedWarnings.indexOf(message);
43
47
 
44
- if (contextualExpectedWarning != null && contextualExpectedWarning === message) {
45
- contextualExpectedWarning = null;
48
+ if (contextualExpectedWarning.length > 0 && contextualExpectedWarning[0] === message) {
49
+ contextualExpectedWarning.shift();
46
50
  } else if (index >= 0) {
47
51
  expectedWarnings.splice(index, 1);
48
52
  } else {
@@ -54,6 +58,8 @@ function disallowWarnings() {
54
58
  });
55
59
  });
56
60
  afterEach(function () {
61
+ contextualExpectedWarning.length = 0;
62
+
57
63
  if (expectedWarnings.length > 0) {
58
64
  var error = new Error('Some expected warnings where not triggered:\n\n' + Array.from(expectedWarnings, function (message) {
59
65
  return " * ".concat(message);
@@ -82,16 +88,26 @@ function expectWarningWillFire(message) {
82
88
 
83
89
 
84
90
  function expectToWarn(message, fn) {
85
- if (contextualExpectedWarning != null) {
91
+ return expectToWarnMany([message], fn);
92
+ }
93
+ /**
94
+ * Expect the callback `fn` to trigger all warning messages (in sequence)
95
+ * or otherwise fail.
96
+ */
97
+
98
+
99
+ function expectToWarnMany(messages, fn) {
100
+ if (contextualExpectedWarning.length > 0) {
86
101
  throw new Error('Cannot nest `expectToWarn()` calls.');
87
102
  }
88
103
 
89
- contextualExpectedWarning = message;
104
+ contextualExpectedWarning.push.apply(contextualExpectedWarning, (0, _toConsumableArray2["default"])(messages));
90
105
  var result = fn();
91
106
 
92
- if (contextualExpectedWarning != null) {
93
- contextualExpectedWarning = null;
94
- throw new Error("Expected callback to warn: ".concat(message));
107
+ if (contextualExpectedWarning.length > 0) {
108
+ var notFired = contextualExpectedWarning.toString();
109
+ contextualExpectedWarning.length = 0;
110
+ throw new Error("Expected callback to warn: ".concat(notFired));
95
111
  }
96
112
 
97
113
  return result;
@@ -100,5 +116,6 @@ function expectToWarn(message, fn) {
100
116
  module.exports = {
101
117
  disallowWarnings: disallowWarnings,
102
118
  expectWarningWillFire: expectWarningWillFire,
103
- expectToWarn: expectToWarn
119
+ expectToWarn: expectToWarn,
120
+ expectToWarnMany: expectToWarnMany
104
121
  };
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.1",
4
+ "version": "13.1.1",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay"
@@ -9,11 +9,15 @@
9
9
  "license": "MIT",
10
10
  "homepage": "https://relay.dev",
11
11
  "bugs": "https://github.com/facebook/relay/issues",
12
- "repository": "facebook/relay",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/facebook/relay.git",
15
+ "directory": "packages/relay-test-utils-internal"
16
+ },
13
17
  "dependencies": {
14
18
  "@babel/runtime": "^7.0.0",
15
19
  "fbjs": "^3.0.2",
16
- "relay-runtime": "13.0.1"
20
+ "relay-runtime": "13.1.1"
17
21
  },
18
22
  "directories": {
19
23
  "": "./"
@@ -1,4 +1,4 @@
1
1
  /**
2
- * Relay v13.0.1
2
+ * Relay v13.1.1
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,c=o.generateTestsFromFixtures,a=t(10),u=t(12),s=t(14),f=t(15),l=f.disallowWarnings,p=f.expectToWarn,d=f.expectWarningWillFire,g=t(16),h=g.createMockEnvironment,x=g.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:h,describeWithFeatureFlags:r,expectToWarn:p,expectWarningWillFire:d,disallowWarnings:l,FIXTURE_TAG:i,generateTestsFromFixtures:c,matchers:a,printAST:u,simpleClone:s,unwrapContainer:x}},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),c=t(9),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 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(c.join(e,t),"utf8"),f=o(s,n,t);expect((u={},(0,r.default)(u,a,!0),(0,r.default)(u,"input",s),(0,r.default)(u,"output",f),u)).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(11);if(!a.mock)throw new Error("toWarn(): Requires `jest.mock('warning')`.");var u=a.mock.calls.length;e();var s=a.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(c(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(c(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",c=t+" ",a=(0,r.default)(n);try{for(a.s();!(o=a.n()).done;){var u=o.value;i+=c+e(u,c)+",\n"}}catch(e){a.e(e)}finally{a.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=!1,o=[],i=null;e.exports={disallowWarnings:function(){if(r)throw new Error("`disallowWarnings` should be called at most once");r=!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),c=2;c<t;c++)r[c-2]=arguments[c];if(!e){var a=0,u=n.replace(/%s/g,(function(){return String(r[a++])})),s=o.indexOf(u);if(null!=i&&i===u)i=null;else{if(!(s>=0))throw console.error("Unexpected Warning: "+u),new Error("Warning: "+u);o.splice(s,1)}}}))})),afterEach((function(){if(o.length>0){var e=new Error("Some expected warnings where not triggered:\n\n"+Array.from(o,(function(e){return" * ".concat(e)})).join("\n")+"\n");throw o.length=0,e}}))},expectWarningWillFire:function(e){if(!r)throw new Error("`disallowWarnings` needs to be called before `expectWarningWillFire`");o.push(e)},expectToWarn:function(e,n){if(null!=i)throw new Error("Cannot nest `expectToWarn()` calls.");i=e;var t=n();if(null!=i)throw i=null,new Error("Expected callback to warn: ".concat(e));return t}}},function(e,n){e.exports=require("relay-test-utils")}]);
4
+ module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=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")}]);
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Relay v13.0.1
2
+ * Relay v13.1.1
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,c=o.generateTestsFromFixtures,a=t(10),u=t(12),s=t(14),f=t(15),l=f.disallowWarnings,p=f.expectToWarn,d=f.expectWarningWillFire,g=t(16),h=g.createMockEnvironment,x=g.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:h,describeWithFeatureFlags:r,expectToWarn:p,expectWarningWillFire:d,disallowWarnings:l,FIXTURE_TAG:i,generateTestsFromFixtures:c,matchers:a,printAST:u,simpleClone:s,unwrapContainer:x}},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),c=t(9),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 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(c.join(e,t),"utf8"),f=o(s,n,t);expect((u={},(0,r.default)(u,a,!0),(0,r.default)(u,"input",s),(0,r.default)(u,"output",f),u)).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(11);if(!a.mock)throw new Error("toWarn(): Requires `jest.mock('warning')`.");var u=a.mock.calls.length;e();var s=a.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(c(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(c(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",c=t+" ",a=(0,r.default)(n);try{for(a.s();!(o=a.n()).done;){var u=o.value;i+=c+e(u,c)+",\n"}}catch(e){a.e(e)}finally{a.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=!1,o=[],i=null;e.exports={disallowWarnings:function(){if(r)throw new Error("`disallowWarnings` should be called at most once");r=!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),c=2;c<t;c++)r[c-2]=arguments[c];if(!e){var a=0,u=n.replace(/%s/g,(function(){return String(r[a++])})),s=o.indexOf(u);if(null!=i&&i===u)i=null;else{if(!(s>=0))throw console.error("Unexpected Warning: "+u),new Error("Warning: "+u);o.splice(s,1)}}}))})),afterEach((function(){if(o.length>0){var e=new Error("Some expected warnings where not triggered:\n\n"+Array.from(o,(function(e){return" * ".concat(e)})).join("\n")+"\n");throw o.length=0,e}}))},expectWarningWillFire:function(e){if(!r)throw new Error("`disallowWarnings` needs to be called before `expectWarningWillFire`");o.push(e)},expectToWarn:function(e,n){if(null!=i)throw new Error("Cannot nest `expectToWarn()` calls.");i=e;var t=n();if(null!=i)throw i=null,new Error("Expected callback to warn: ".concat(e));return t}}},function(e,n){e.exports=require("relay-test-utils")}]);
9
+ module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=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")}]);
package/warnings.js.flow CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  let installed = false;
17
17
  const expectedWarnings: Array<string> = [];
18
- let contextualExpectedWarning: string | null = null;
18
+ const contextualExpectedWarning: Array<string> = [];
19
19
 
20
20
  /**
21
21
  * Mocks the `warning` module to turn warnings into errors. Any expected
@@ -37,10 +37,10 @@ function disallowWarnings(): void {
37
37
  const index = expectedWarnings.indexOf(message);
38
38
 
39
39
  if (
40
- contextualExpectedWarning != null &&
41
- contextualExpectedWarning === message
40
+ contextualExpectedWarning.length > 0 &&
41
+ contextualExpectedWarning[0] === message
42
42
  ) {
43
- contextualExpectedWarning = null;
43
+ contextualExpectedWarning.shift();
44
44
  } else if (index >= 0) {
45
45
  expectedWarnings.splice(index, 1);
46
46
  } else {
@@ -52,6 +52,7 @@ function disallowWarnings(): void {
52
52
  });
53
53
  });
54
54
  afterEach(() => {
55
+ contextualExpectedWarning.length = 0;
55
56
  if (expectedWarnings.length > 0) {
56
57
  const error = new Error(
57
58
  'Some expected warnings where not triggered:\n\n' +
@@ -81,14 +82,23 @@ function expectWarningWillFire(message: string): void {
81
82
  * Expect the callback `fn` to trigger the warning message and otherwise fail.
82
83
  */
83
84
  function expectToWarn<T>(message: string, fn: () => T): T {
84
- if (contextualExpectedWarning != null) {
85
+ return expectToWarnMany([message], fn);
86
+ }
87
+
88
+ /**
89
+ * Expect the callback `fn` to trigger all warning messages (in sequence)
90
+ * or otherwise fail.
91
+ */
92
+ function expectToWarnMany<T>(messages: Array<string>, fn: () => T): T {
93
+ if (contextualExpectedWarning.length > 0) {
85
94
  throw new Error('Cannot nest `expectToWarn()` calls.');
86
95
  }
87
- contextualExpectedWarning = message;
96
+ contextualExpectedWarning.push(...messages);
88
97
  const result = fn();
89
- if (contextualExpectedWarning != null) {
90
- contextualExpectedWarning = null;
91
- throw new Error(`Expected callback to warn: ${message}`);
98
+ if (contextualExpectedWarning.length > 0) {
99
+ const notFired = contextualExpectedWarning.toString();
100
+ contextualExpectedWarning.length = 0;
101
+ throw new Error(`Expected callback to warn: ${notFired}`);
92
102
  }
93
103
  return result;
94
104
  }
@@ -97,4 +107,5 @@ module.exports = {
97
107
  disallowWarnings,
98
108
  expectWarningWillFire,
99
109
  expectToWarn,
110
+ expectToWarnMany,
100
111
  };