relay-test-utils-internal 12.0.0 → 13.0.0-rc.0
Sign up to get free protection for your applications and to get access to all the features.
- package/describeWithFeatureFlags.js.flow +70 -0
- package/generateTestsFromFixtures.js.flow +5 -4
- package/index.js +1 -1
- package/index.js.flow +23 -12
- package/lib/describeWithFeatureFlags.js +46 -0
- package/lib/generateTestsFromFixtures.js +2 -2
- package/lib/index.js +26 -18
- package/lib/testschema.graphql +0 -1
- package/package.json +2 -6
- package/relay-test-utils-internal.js +2 -2
- package/relay-test-utils-internal.min.js +2 -2
- package/TestSchema.js.flow +0 -33
- package/lib/TestSchema.js +0 -28
- package/lib/parseGraphQLText.js +0 -30
- package/parseGraphQLText.js.flow +0 -41
@@ -0,0 +1,70 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @flow
|
8
|
+
* @format
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Run a test suite under multiple sets of feature flags.
|
13
|
+
* Beware that calling jest.resetModules() within the suite may break this.
|
14
|
+
*/
|
15
|
+
|
16
|
+
// flowlint ambiguous-object-type:error
|
17
|
+
|
18
|
+
'use strict';
|
19
|
+
|
20
|
+
import type {FeatureFlags} from '../relay-runtime/util/RelayFeatureFlags';
|
21
|
+
|
22
|
+
// This function is for running within a test environment, so we use globals
|
23
|
+
// available within tests -- taken from:
|
24
|
+
// i code/www/[5ee5e1d71a05e9f58ded3c1c22b810666383164f]/flow/shared/libdefs/jest.js
|
25
|
+
type JestDoneFn = {
|
26
|
+
(): void,
|
27
|
+
fail: (error: Error) => void,
|
28
|
+
...
|
29
|
+
};
|
30
|
+
declare function afterEach(
|
31
|
+
fn: (done: JestDoneFn) => ?Promise<mixed>,
|
32
|
+
timeout?: number,
|
33
|
+
): void;
|
34
|
+
declare function beforeEach(
|
35
|
+
fn: (done: JestDoneFn) => ?Promise<mixed>,
|
36
|
+
timeout?: number,
|
37
|
+
): void;
|
38
|
+
declare var describe: {
|
39
|
+
(name: JestTestName, fn: () => void): void,
|
40
|
+
each(
|
41
|
+
...table: $ReadOnlyArray<Array<mixed> | mixed> | [Array<string>, string]
|
42
|
+
): (
|
43
|
+
name: JestTestName,
|
44
|
+
fn?: (...args: Array<any>) => ?Promise<mixed>,
|
45
|
+
timeout?: number,
|
46
|
+
) => void,
|
47
|
+
...
|
48
|
+
};
|
49
|
+
|
50
|
+
function describeWithFeatureFlags(
|
51
|
+
flagSets: Array<$Shape<FeatureFlags>>,
|
52
|
+
description: string,
|
53
|
+
body: () => void,
|
54
|
+
): void {
|
55
|
+
describe.each(flagSets)(`${description} - Feature flags: %o`, flags => {
|
56
|
+
let originalFlags;
|
57
|
+
beforeEach(() => {
|
58
|
+
const {RelayFeatureFlags} = require('relay-runtime');
|
59
|
+
originalFlags = {...RelayFeatureFlags};
|
60
|
+
Object.assign(RelayFeatureFlags, flags);
|
61
|
+
});
|
62
|
+
afterEach(() => {
|
63
|
+
const {RelayFeatureFlags} = require('relay-runtime'); // re-import in case of jest module resets
|
64
|
+
Object.assign(RelayFeatureFlags, originalFlags);
|
65
|
+
});
|
66
|
+
body();
|
67
|
+
});
|
68
|
+
}
|
69
|
+
|
70
|
+
module.exports = describeWithFeatureFlags;
|
@@ -9,8 +9,8 @@
|
|
9
9
|
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
const fs = require('fs');
|
13
12
|
const getOutputForFixture = require('./getOutputForFixture');
|
13
|
+
const fs = require('fs');
|
14
14
|
const path = require('path');
|
15
15
|
|
16
16
|
/* global expect,test */
|
@@ -49,9 +49,10 @@ function generateTestsFromFixtures(
|
|
49
49
|
|
50
50
|
const onlyFixtures = fixtures.filter(name => name.startsWith('only.'));
|
51
51
|
if (onlyFixtures.length) {
|
52
|
-
test.skip.each(
|
53
|
-
|
54
|
-
|
52
|
+
test.skip.each(fixtures.filter(name => !name.startsWith('only.')))(
|
53
|
+
'matches expected output: %s',
|
54
|
+
() => {},
|
55
|
+
);
|
55
56
|
fixtures = onlyFixtures;
|
56
57
|
}
|
57
58
|
test.each(fixtures)('matches expected output: %s', file => {
|
package/index.js
CHANGED
package/index.js.flow
CHANGED
@@ -12,39 +12,50 @@
|
|
12
12
|
|
13
13
|
'use strict';
|
14
14
|
|
15
|
-
const
|
16
|
-
|
17
|
-
const parseGraphQLText = require('./parseGraphQLText');
|
18
|
-
const printAST = require('./printAST');
|
19
|
-
const simpleClone = require('./simpleClone');
|
20
|
-
|
21
|
-
const {TestSchema, testSchemaPath} = require('./TestSchema');
|
15
|
+
const describeWithFeatureFlags = require('./describeWithFeatureFlags');
|
22
16
|
const {
|
23
|
-
generateTestsFromFixtures,
|
24
17
|
FIXTURE_TAG,
|
18
|
+
generateTestsFromFixtures,
|
25
19
|
} = require('./generateTestsFromFixtures');
|
20
|
+
const Matchers = require('./Matchers');
|
21
|
+
const printAST = require('./printAST');
|
22
|
+
const simpleClone = require('./simpleClone');
|
26
23
|
const {
|
24
|
+
disallowWarnings,
|
27
25
|
expectToWarn,
|
28
26
|
expectWarningWillFire,
|
29
|
-
disallowWarnings,
|
30
27
|
} = require('./warnings');
|
31
28
|
const {createMockEnvironment, unwrapContainer} = require('relay-test-utils');
|
32
29
|
|
30
|
+
// Apparently, in node v16 (because now they are using V8 V9.something)
|
31
|
+
// the content of the TypeError has changed, and now some of our tests
|
32
|
+
// stated to fail.
|
33
|
+
// This is a temporary work-around to make test pass, but we need to
|
34
|
+
// figure out a cleaner way of testing this.
|
35
|
+
function cannotReadPropertyOfUndefined__DEPRECATED(
|
36
|
+
propertyName: string,
|
37
|
+
): string {
|
38
|
+
if (process.version.match(/^v16\.(.+)$/)) {
|
39
|
+
return `Cannot read properties of undefined (reading '${propertyName}')`;
|
40
|
+
} else {
|
41
|
+
return `Cannot read property '${propertyName}' of undefined`;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
33
45
|
/**
|
34
46
|
* The public interface to Relay Test Utils.
|
35
47
|
*/
|
36
48
|
module.exports = {
|
49
|
+
cannotReadPropertyOfUndefined__DEPRECATED,
|
37
50
|
createMockEnvironment,
|
51
|
+
describeWithFeatureFlags,
|
38
52
|
expectToWarn,
|
39
53
|
expectWarningWillFire,
|
40
54
|
disallowWarnings,
|
41
55
|
FIXTURE_TAG,
|
42
56
|
generateTestsFromFixtures,
|
43
57
|
matchers: Matchers,
|
44
|
-
parseGraphQLText,
|
45
58
|
printAST,
|
46
59
|
simpleClone,
|
47
|
-
TestSchema,
|
48
|
-
testSchemaPath,
|
49
60
|
unwrapContainer,
|
50
61
|
};
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*
|
8
|
+
* @format
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Run a test suite under multiple sets of feature flags.
|
13
|
+
* Beware that calling jest.resetModules() within the suite may break this.
|
14
|
+
*/
|
15
|
+
// flowlint ambiguous-object-type:error
|
16
|
+
'use strict';
|
17
|
+
|
18
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
19
|
+
|
20
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
21
|
+
|
22
|
+
// This function is for running within a test environment, so we use globals
|
23
|
+
// available within tests -- taken from:
|
24
|
+
// i code/www/[5ee5e1d71a05e9f58ded3c1c22b810666383164f]/flow/shared/libdefs/jest.js
|
25
|
+
function describeWithFeatureFlags(flagSets, description, body) {
|
26
|
+
describe.each(flagSets)("".concat(description, " - Feature flags: %o"), function (flags) {
|
27
|
+
var originalFlags;
|
28
|
+
beforeEach(function () {
|
29
|
+
var _require = require('relay-runtime'),
|
30
|
+
RelayFeatureFlags = _require.RelayFeatureFlags;
|
31
|
+
|
32
|
+
originalFlags = (0, _objectSpread2["default"])({}, RelayFeatureFlags);
|
33
|
+
Object.assign(RelayFeatureFlags, flags);
|
34
|
+
});
|
35
|
+
afterEach(function () {
|
36
|
+
var _require2 = require('relay-runtime'),
|
37
|
+
RelayFeatureFlags = _require2.RelayFeatureFlags; // re-import in case of jest module resets
|
38
|
+
|
39
|
+
|
40
|
+
Object.assign(RelayFeatureFlags, originalFlags);
|
41
|
+
});
|
42
|
+
body();
|
43
|
+
});
|
44
|
+
}
|
45
|
+
|
46
|
+
module.exports = describeWithFeatureFlags;
|
@@ -12,10 +12,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
12
12
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
14
14
|
|
15
|
-
var fs = require('fs');
|
16
|
-
|
17
15
|
var getOutputForFixture = require('./getOutputForFixture');
|
18
16
|
|
17
|
+
var fs = require('fs');
|
18
|
+
|
19
19
|
var path = require('path');
|
20
20
|
/* global expect,test */
|
21
21
|
|
package/lib/index.js
CHANGED
@@ -10,47 +10,55 @@
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
11
11
|
'use strict';
|
12
12
|
|
13
|
-
var
|
13
|
+
var describeWithFeatureFlags = require('./describeWithFeatureFlags');
|
14
|
+
|
15
|
+
var _require = require('./generateTestsFromFixtures'),
|
16
|
+
FIXTURE_TAG = _require.FIXTURE_TAG,
|
17
|
+
generateTestsFromFixtures = _require.generateTestsFromFixtures;
|
14
18
|
|
15
|
-
var
|
19
|
+
var Matchers = require('./Matchers');
|
16
20
|
|
17
21
|
var printAST = require('./printAST');
|
18
22
|
|
19
23
|
var simpleClone = require('./simpleClone');
|
20
24
|
|
21
|
-
var
|
22
|
-
|
23
|
-
|
25
|
+
var _require2 = require('./warnings'),
|
26
|
+
disallowWarnings = _require2.disallowWarnings,
|
27
|
+
expectToWarn = _require2.expectToWarn,
|
28
|
+
expectWarningWillFire = _require2.expectWarningWillFire;
|
24
29
|
|
25
|
-
var
|
26
|
-
|
27
|
-
|
30
|
+
var _require3 = require('relay-test-utils'),
|
31
|
+
createMockEnvironment = _require3.createMockEnvironment,
|
32
|
+
unwrapContainer = _require3.unwrapContainer; // Apparently, in node v16 (because now they are using V8 V9.something)
|
33
|
+
// the content of the TypeError has changed, and now some of our tests
|
34
|
+
// stated to fail.
|
35
|
+
// This is a temporary work-around to make test pass, but we need to
|
36
|
+
// figure out a cleaner way of testing this.
|
28
37
|
|
29
|
-
var _require3 = require('./warnings'),
|
30
|
-
expectToWarn = _require3.expectToWarn,
|
31
|
-
expectWarningWillFire = _require3.expectWarningWillFire,
|
32
|
-
disallowWarnings = _require3.disallowWarnings;
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
39
|
+
function cannotReadPropertyOfUndefined__DEPRECATED(propertyName) {
|
40
|
+
if (process.version.match(/^v16\.(.+)$/)) {
|
41
|
+
return "Cannot read properties of undefined (reading '".concat(propertyName, "')");
|
42
|
+
} else {
|
43
|
+
return "Cannot read property '".concat(propertyName, "' of undefined");
|
44
|
+
}
|
45
|
+
}
|
37
46
|
/**
|
38
47
|
* The public interface to Relay Test Utils.
|
39
48
|
*/
|
40
49
|
|
41
50
|
|
42
51
|
module.exports = {
|
52
|
+
cannotReadPropertyOfUndefined__DEPRECATED: cannotReadPropertyOfUndefined__DEPRECATED,
|
43
53
|
createMockEnvironment: createMockEnvironment,
|
54
|
+
describeWithFeatureFlags: describeWithFeatureFlags,
|
44
55
|
expectToWarn: expectToWarn,
|
45
56
|
expectWarningWillFire: expectWarningWillFire,
|
46
57
|
disallowWarnings: disallowWarnings,
|
47
58
|
FIXTURE_TAG: FIXTURE_TAG,
|
48
59
|
generateTestsFromFixtures: generateTestsFromFixtures,
|
49
60
|
matchers: Matchers,
|
50
|
-
parseGraphQLText: parseGraphQLText,
|
51
61
|
printAST: printAST,
|
52
62
|
simpleClone: simpleClone,
|
53
|
-
TestSchema: TestSchema,
|
54
|
-
testSchemaPath: testSchemaPath,
|
55
63
|
unwrapContainer: unwrapContainer
|
56
64
|
};
|
package/lib/testschema.graphql
CHANGED
@@ -56,7 +56,6 @@ type Query {
|
|
56
56
|
usernames(names: [String!]!): [Actor]
|
57
57
|
viewer: Viewer
|
58
58
|
_mutation: Mutation
|
59
|
-
relay_early_flush(query_name: String): [JSDependency!]!
|
60
59
|
fetch__User(id: ID!): User
|
61
60
|
fetch__NonNodeStory(input_fetch_id: ID!): NonNodeStory
|
62
61
|
nonNodeStory(id: ID!): NonNodeStory
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "relay-test-utils-internal",
|
3
3
|
"description": "Internal utilities for testing Relay.",
|
4
|
-
"version": "
|
4
|
+
"version": "13.0.0-rc.0",
|
5
5
|
"keywords": [
|
6
6
|
"graphql",
|
7
7
|
"relay"
|
@@ -13,11 +13,7 @@
|
|
13
13
|
"dependencies": {
|
14
14
|
"@babel/runtime": "^7.0.0",
|
15
15
|
"fbjs": "^3.0.0",
|
16
|
-
"relay-runtime": "
|
17
|
-
"relay-compiler": "12.0.0"
|
18
|
-
},
|
19
|
-
"peerDependencies": {
|
20
|
-
"graphql": "^15.0.0"
|
16
|
+
"relay-runtime": "13.0.0-rc.0"
|
21
17
|
},
|
22
18
|
"directories": {
|
23
19
|
"": "./"
|
@@ -1,4 +1,4 @@
|
|
1
1
|
/**
|
2
|
-
* Relay
|
2
|
+
* Relay v13.0.0-rc.0
|
3
3
|
*/
|
4
|
-
module.exports=function(e){var
|
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")}]);
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/**
|
2
|
-
* Relay
|
2
|
+
* Relay v13.0.0-rc.0
|
3
3
|
*
|
4
4
|
* Copyright (c) Facebook, Inc. and its 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
|
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")}]);
|
package/TestSchema.js.flow
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
* @flow strict-local
|
8
|
-
* @format
|
9
|
-
*/
|
10
|
-
|
11
|
-
// flowlint ambiguous-object-type:error
|
12
|
-
|
13
|
-
'use strict';
|
14
|
-
|
15
|
-
const fs = require('fs');
|
16
|
-
const path = require('path');
|
17
|
-
|
18
|
-
const testSchemaPath = (path.join(__dirname, 'testschema.graphql'): string);
|
19
|
-
|
20
|
-
const {Source} = require('graphql');
|
21
|
-
|
22
|
-
const {
|
23
|
-
Schema: {create},
|
24
|
-
} = require('relay-compiler');
|
25
|
-
import type {Schema} from 'relay-compiler';
|
26
|
-
|
27
|
-
module.exports = ({
|
28
|
-
TestSchema: create(new Source(fs.readFileSync(testSchemaPath, 'utf8'))),
|
29
|
-
testSchemaPath,
|
30
|
-
}: {|
|
31
|
-
+TestSchema: Schema,
|
32
|
-
+testSchemaPath: string,
|
33
|
-
|});
|
package/lib/TestSchema.js
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
*/
|
10
|
-
// flowlint ambiguous-object-type:error
|
11
|
-
'use strict';
|
12
|
-
|
13
|
-
var fs = require('fs');
|
14
|
-
|
15
|
-
var path = require('path');
|
16
|
-
|
17
|
-
var testSchemaPath = path.join(__dirname, 'testschema.graphql');
|
18
|
-
|
19
|
-
var _require = require('graphql'),
|
20
|
-
Source = _require.Source;
|
21
|
-
|
22
|
-
var _require2 = require('relay-compiler'),
|
23
|
-
create = _require2.Schema.create;
|
24
|
-
|
25
|
-
module.exports = {
|
26
|
-
TestSchema: create(new Source(fs.readFileSync(testSchemaPath, 'utf8'))),
|
27
|
-
testSchemaPath: testSchemaPath
|
28
|
-
};
|
package/lib/parseGraphQLText.js
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
*/
|
10
|
-
// flowlint ambiguous-object-type:error
|
11
|
-
'use strict';
|
12
|
-
|
13
|
-
var _require = require('graphql'),
|
14
|
-
parse = _require.parse;
|
15
|
-
|
16
|
-
var _require2 = require('relay-compiler'),
|
17
|
-
Parser = _require2.Parser,
|
18
|
-
convertASTDocuments = _require2.convertASTDocuments;
|
19
|
-
|
20
|
-
function parseGraphQLText(schema, text) {
|
21
|
-
var ast = parse(text);
|
22
|
-
var extendedSchema = schema.extend(ast);
|
23
|
-
var definitions = convertASTDocuments(extendedSchema, [ast], Parser.transform.bind(Parser));
|
24
|
-
return {
|
25
|
-
definitions: definitions,
|
26
|
-
schema: extendedSchema
|
27
|
-
};
|
28
|
-
}
|
29
|
-
|
30
|
-
module.exports = parseGraphQLText;
|
package/parseGraphQLText.js.flow
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
* @flow strict-local
|
8
|
-
* @format
|
9
|
-
*/
|
10
|
-
|
11
|
-
// flowlint ambiguous-object-type:error
|
12
|
-
|
13
|
-
'use strict';
|
14
|
-
|
15
|
-
const {parse} = require('graphql');
|
16
|
-
const {Parser, convertASTDocuments} = require('relay-compiler');
|
17
|
-
|
18
|
-
import type {Fragment, Root, Schema} from 'relay-compiler';
|
19
|
-
|
20
|
-
function parseGraphQLText(
|
21
|
-
schema: Schema,
|
22
|
-
text: string,
|
23
|
-
): {
|
24
|
-
definitions: $ReadOnlyArray<Fragment | Root>,
|
25
|
-
schema: Schema,
|
26
|
-
...
|
27
|
-
} {
|
28
|
-
const ast = parse(text);
|
29
|
-
const extendedSchema = schema.extend(ast);
|
30
|
-
const definitions = convertASTDocuments(
|
31
|
-
extendedSchema,
|
32
|
-
[ast],
|
33
|
-
Parser.transform.bind(Parser),
|
34
|
-
);
|
35
|
-
return {
|
36
|
-
definitions,
|
37
|
-
schema: extendedSchema,
|
38
|
-
};
|
39
|
-
}
|
40
|
-
|
41
|
-
module.exports = parseGraphQLText;
|