relay-test-utils-internal 20.0.0 → 20.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,7 +40,7 @@ expect.addSnapshotSerializer({
40
40
  */
41
41
  function generateTestsFromFixtures(
42
42
  fixturesPath: string,
43
- operation: (input: string) => string,
43
+ operation: (input: string) => Promise<string>,
44
44
  ): void {
45
45
  let fixtures = fs.readdirSync(fixturesPath);
46
46
 
@@ -56,9 +56,9 @@ function generateTestsFromFixtures(
56
56
  );
57
57
  fixtures = onlyFixtures;
58
58
  }
59
- test.each(fixtures)('matches expected output: %s', file => {
59
+ test.each(fixtures)('matches expected output: %s', async file => {
60
60
  const input = fs.readFileSync(path.join(fixturesPath, file), 'utf8');
61
- const output = getOutputForFixture(input, operation, file);
61
+ const output = await getOutputForFixture(input, operation, file);
62
62
  expect({
63
63
  [FIXTURE_TAG]: true,
64
64
  input,
@@ -11,17 +11,17 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- function getOutputForFixture(
14
+ async function getOutputForFixture(
15
15
  input: string,
16
- operation: (input: string) => string,
16
+ operation: (input: string) => Promise<string> | string,
17
17
  file: string,
18
- ): string {
18
+ ): Promise<string> {
19
19
  const shouldThrow =
20
20
  /^# *expected-to-throw/.test(input) || /\.error\.\w+$/.test(file);
21
21
  if (shouldThrow) {
22
22
  let result;
23
23
  try {
24
- result = operation(input);
24
+ result = await operation(input);
25
25
  } catch (e) {
26
26
  return `THROWN EXCEPTION:\n\n${e.toString()}`;
27
27
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v20.0.0
2
+ * Relay v20.1.1
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator").default;
4
5
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
5
6
  var getOutputForFixture = require('./getOutputForFixture');
6
7
  var fs = require('fs');
@@ -30,12 +31,17 @@ function generateTestsFromFixtures(fixturesPath, operation) {
30
31
  }))('matches expected output: %s', function () {});
31
32
  fixtures = onlyFixtures;
32
33
  }
33
- test.each(fixtures)('matches expected output: %s', function (file) {
34
- var _expect;
35
- var input = fs.readFileSync(path.join(fixturesPath, file), 'utf8');
36
- var output = getOutputForFixture(input, operation, file);
37
- expect((_expect = {}, (0, _defineProperty2["default"])(_expect, FIXTURE_TAG, true), (0, _defineProperty2["default"])(_expect, "input", input), (0, _defineProperty2["default"])(_expect, "output", output), _expect)).toMatchSnapshot();
38
- });
34
+ test.each(fixtures)('matches expected output: %s', /*#__PURE__*/function () {
35
+ var _ref = _asyncToGenerator(function* (file) {
36
+ var _expect;
37
+ var input = fs.readFileSync(path.join(fixturesPath, file), 'utf8');
38
+ var output = yield getOutputForFixture(input, operation, file);
39
+ expect((_expect = {}, (0, _defineProperty2["default"])(_expect, FIXTURE_TAG, true), (0, _defineProperty2["default"])(_expect, "input", input), (0, _defineProperty2["default"])(_expect, "output", output), _expect)).toMatchSnapshot();
40
+ });
41
+ return function (_x) {
42
+ return _ref.apply(this, arguments);
43
+ };
44
+ }());
39
45
  }
40
46
  module.exports = {
41
47
  generateTestsFromFixtures: generateTestsFromFixtures,
@@ -1,17 +1,24 @@
1
1
  'use strict';
2
2
 
3
- function getOutputForFixture(input, operation, file) {
4
- var shouldThrow = /^# *expected-to-throw/.test(input) || /\.error\.\w+$/.test(file);
5
- if (shouldThrow) {
6
- var result;
7
- try {
8
- result = operation(input);
9
- } catch (e) {
10
- return "THROWN EXCEPTION:\n\n".concat(e.toString());
3
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator").default;
4
+ function getOutputForFixture(_x, _x2, _x3) {
5
+ return _getOutputForFixture.apply(this, arguments);
6
+ }
7
+ function _getOutputForFixture() {
8
+ _getOutputForFixture = _asyncToGenerator(function* (input, operation, file) {
9
+ var shouldThrow = /^# *expected-to-throw/.test(input) || /\.error\.\w+$/.test(file);
10
+ if (shouldThrow) {
11
+ var result;
12
+ try {
13
+ result = yield operation(input);
14
+ } catch (e) {
15
+ return "THROWN EXCEPTION:\n\n".concat(e.toString());
16
+ }
17
+ throw new Error("Expected test file '".concat(file, "' to throw, but it passed:\n").concat(result));
18
+ } else {
19
+ return operation(input);
11
20
  }
12
- throw new Error("Expected test file '".concat(file, "' to throw, but it passed:\n").concat(result));
13
- } else {
14
- return operation(input);
15
- }
21
+ });
22
+ return _getOutputForFixture.apply(this, arguments);
16
23
  }
17
24
  module.exports = getOutputForFixture;
@@ -967,7 +967,7 @@ type PlainUserRenderer {
967
967
  }
968
968
 
969
969
  union UserNameRenderer =
970
- PlainUserNameRenderer
970
+ | PlainUserNameRenderer
971
971
  | MarkdownUserNameRenderer
972
972
  | CustomNameRenderer
973
973
 
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": "20.0.0",
4
+ "version": "20.1.1",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay"
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.25.0",
19
19
  "fbjs": "^3.0.2",
20
- "relay-runtime": "20.0.0"
20
+ "relay-runtime": "20.1.1"
21
21
  },
22
22
  "directories": {
23
23
  "": "./"