@builder.io/sdk-react-native 0.0.1-44 → 0.0.1-50

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +1 -1
  3. package/src/blocks/button.js +23 -73
  4. package/src/blocks/button.lite.tsx +3 -3
  5. package/src/blocks/columns.js +56 -288
  6. package/src/blocks/columns.lite.tsx +22 -22
  7. package/src/blocks/custom-code.js +46 -76
  8. package/src/blocks/custom-code.lite.tsx +11 -19
  9. package/src/blocks/embed.js +46 -69
  10. package/src/blocks/embed.lite.tsx +11 -15
  11. package/src/blocks/form.js +194 -491
  12. package/src/blocks/form.lite.tsx +51 -51
  13. package/src/blocks/fragment.js +8 -16
  14. package/src/blocks/fragment.lite.tsx +2 -2
  15. package/src/blocks/image.js +91 -113
  16. package/src/blocks/image.lite.tsx +12 -13
  17. package/src/blocks/img.js +28 -51
  18. package/src/blocks/img.lite.tsx +6 -6
  19. package/src/blocks/input.js +28 -100
  20. package/src/blocks/input.lite.tsx +4 -4
  21. package/src/blocks/raw-text.js +10 -16
  22. package/src/blocks/raw-text.lite.tsx +3 -8
  23. package/src/blocks/section.js +23 -71
  24. package/src/blocks/section.lite.tsx +3 -3
  25. package/src/blocks/select.js +28 -78
  26. package/src/blocks/select.lite.tsx +5 -5
  27. package/src/blocks/submit-button.js +21 -47
  28. package/src/blocks/submit-button.lite.tsx +2 -2
  29. package/src/blocks/symbol.js +71 -20
  30. package/src/blocks/symbol.lite.tsx +48 -8
  31. package/src/blocks/text.js +27 -40
  32. package/src/blocks/text.lite.tsx +3 -8
  33. package/src/blocks/textarea.js +24 -60
  34. package/src/blocks/textarea.lite.tsx +2 -2
  35. package/src/blocks/video.js +66 -71
  36. package/src/blocks/video.lite.tsx +5 -5
  37. package/src/components/block-styles.js +4 -2
  38. package/src/components/block-styles.lite.tsx +2 -2
  39. package/src/components/error-boundary.js +9 -11
  40. package/src/components/error-boundary.lite.tsx +2 -2
  41. package/src/components/render-block.js +44 -100
  42. package/src/components/render-block.lite.tsx +23 -28
  43. package/src/components/render-blocks.js +41 -60
  44. package/src/components/render-blocks.lite.tsx +20 -14
  45. package/src/components/render-content.js +189 -142
  46. package/src/components/render-content.lite.tsx +166 -60
  47. package/src/constants/device-sizes.js +11 -8
  48. package/src/context/builder.context.js +10 -3
  49. package/src/functions/evaluate.js +20 -20
  50. package/src/functions/event-handler-name.js +3 -1
  51. package/src/functions/get-block-actions.js +17 -16
  52. package/src/functions/get-block-component-options.js +9 -16
  53. package/src/functions/get-block-properties.js +14 -18
  54. package/src/functions/get-block-styles.js +17 -34
  55. package/src/functions/get-block-tag.js +4 -2
  56. package/src/functions/get-builder-search-params/fn.test.js +14 -0
  57. package/src/functions/get-builder-search-params/index.js +23 -0
  58. package/src/functions/get-content/fn.test.js +32 -0
  59. package/src/functions/get-content/index.js +138 -0
  60. package/src/functions/get-fetch.js +7 -5
  61. package/src/functions/get-global-this.js +7 -5
  62. package/src/functions/get-processed-block.js +13 -17
  63. package/src/functions/get-processed-block.test.js +17 -16
  64. package/src/functions/get-target.js +4 -2
  65. package/src/functions/if-target.js +3 -1
  66. package/src/functions/is-browser.js +4 -2
  67. package/src/functions/is-editing.js +5 -5
  68. package/src/functions/is-iframe.js +4 -2
  69. package/src/functions/is-previewing.js +6 -4
  70. package/src/functions/is-react-native.js +3 -1
  71. package/src/functions/macro-eval.js +5 -2
  72. package/src/functions/on-change.js +7 -4
  73. package/src/functions/on-change.test.js +9 -10
  74. package/src/functions/previewing-model-name.js +5 -3
  75. package/src/functions/register-component.js +27 -38
  76. package/src/functions/register.js +10 -8
  77. package/src/functions/set-editor-settings.js +7 -5
  78. package/src/functions/set.js +5 -14
  79. package/src/functions/set.test.js +13 -14
  80. package/src/functions/track.js +12 -6
  81. package/src/functions/transform-block.js +13 -17
  82. package/src/index-helpers/blocks-exports.js +19 -0
  83. package/src/index-helpers/top-of-file.js +2 -0
  84. package/src/index.js +11 -26
  85. package/src/scripts/init-editing.js +40 -64
  86. package/src/types/typescript.js +1 -0
  87. package/src/functions/get-content.js +0 -152
  88. package/src/functions/get-content.test.js +0 -58
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { isBrowser } from './is-browser';
2
+ import { isBrowser } from "./is-browser";
3
3
  const registry = {};
4
4
  function register(type, info) {
5
5
  let typeList = registry[type];
@@ -9,20 +9,22 @@ function register(type, info) {
9
9
  typeList.push(info);
10
10
  if (isBrowser()) {
11
11
  const message = {
12
- type: 'builder.register',
12
+ type: "builder.register",
13
13
  data: {
14
14
  type,
15
- info,
16
- },
15
+ info
16
+ }
17
17
  };
18
18
  try {
19
- parent.postMessage(message, '*');
19
+ parent.postMessage(message, "*");
20
20
  if (parent !== window) {
21
- window.postMessage(message, '*');
21
+ window.postMessage(message, "*");
22
22
  }
23
23
  } catch (err) {
24
- console.debug('Could not postmessage', err);
24
+ console.debug("Could not postmessage", err);
25
25
  }
26
26
  }
27
27
  }
28
- export { register };
28
+ export {
29
+ register
30
+ };
@@ -1,14 +1,16 @@
1
1
  import * as React from 'react';
2
- import { isBrowser } from './is-browser';
2
+ import { isBrowser } from "./is-browser";
3
3
  const settings = {};
4
4
  function setEditorSettings(newSettings) {
5
5
  if (isBrowser()) {
6
6
  Object.assign(settings, newSettings);
7
7
  const message = {
8
- type: 'builder.settingsChange',
9
- data: settings,
8
+ type: "builder.settingsChange",
9
+ data: settings
10
10
  };
11
- parent.postMessage(message, '*');
11
+ parent.postMessage(message, "*");
12
12
  }
13
13
  }
14
- export { setEditorSettings };
14
+ export {
15
+ setEditorSettings
16
+ };
@@ -3,19 +3,10 @@ const set = (obj, _path, value) => {
3
3
  if (Object(obj) !== obj) {
4
4
  return obj;
5
5
  }
6
- const path = Array.isArray(_path)
7
- ? _path
8
- : _path.toString().match(/[^.[\]]+/g);
9
- path
10
- .slice(0, -1)
11
- .reduce(
12
- (a, c, i) =>
13
- Object(a[c]) === a[c]
14
- ? a[c]
15
- : (a[c] =
16
- Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}),
17
- obj
18
- )[path[path.length - 1]] = value;
6
+ const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
7
+ path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
19
8
  return obj;
20
9
  };
21
- export { set };
10
+ export {
11
+ set
12
+ };
@@ -1,18 +1,17 @@
1
1
  import * as React from 'react';
2
- import { expect, test } from '@jest/globals';
3
- import { set } from './set';
4
- test('can shallow set a property', () => {
5
- const obj = { foo: 'bar' };
6
- set(obj, 'foo', 'baz');
7
- expect(obj.foo).toBe('baz');
2
+ import { set } from "./set";
3
+ test("can shallow set a property", () => {
4
+ const obj = { foo: "bar" };
5
+ set(obj, "foo", "baz");
6
+ expect(obj.foo).toBe("baz");
8
7
  });
9
- test('can deeply set a property', () => {
10
- const obj = { foo: 'bar' };
11
- set(obj, 'foo.bar', 'baz');
12
- expect(obj.foo.bar).toBe('baz');
8
+ test("can deeply set a property", () => {
9
+ const obj = { foo: "bar" };
10
+ set(obj, "foo.bar", "baz");
11
+ expect(obj.foo.bar).toBe("baz");
13
12
  });
14
- test('can deeply create arrays', () => {
15
- const obj = { foo: 'bar' };
16
- set(obj, 'foo.bar.0', 'hi');
17
- expect(obj.foo.bar).toEqual(['hi']);
13
+ test("can deeply create arrays", () => {
14
+ const obj = { foo: "bar" };
15
+ set(obj, "foo.bar.0", "hi");
16
+ expect(obj.foo.bar).toEqual(["hi"]);
18
17
  });
@@ -1,17 +1,23 @@
1
1
  import * as React from 'react';
2
- import { isBrowser } from './is-browser';
3
- import { isReactNative } from './is-react-native';
2
+ import { isBrowser } from "./is-browser";
3
+ import { isEditing } from "./is-editing";
4
+ import { isReactNative } from "./is-react-native";
4
5
  function track(event, properties) {
6
+ if (isEditing()) {
7
+ return;
8
+ }
5
9
  if (!(isBrowser() || isReactNative())) {
6
10
  return;
7
11
  }
8
12
  return fetch(`https://builder.io/api/v1/track`, {
9
- method: 'POST',
13
+ method: "POST",
10
14
  body: JSON.stringify({ events: [{ type: event, data: properties }] }),
11
15
  headers: {
12
- 'content-type': 'application/json',
16
+ "content-type": "application/json"
13
17
  },
14
- mode: 'cors',
18
+ mode: "cors"
15
19
  });
16
20
  }
17
- export { track };
21
+ export {
22
+ track
23
+ };
@@ -5,38 +5,34 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
5
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) =>
9
- key in obj
10
- ? __defProp(obj, key, {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value,
15
- })
16
- : (obj[key] = value);
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
9
  var __spreadValues = (a, b) => {
18
10
  for (var prop in b || (b = {}))
19
- if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
20
13
  if (__getOwnPropSymbols)
21
14
  for (var prop of __getOwnPropSymbols(b)) {
22
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
23
17
  }
24
18
  return a;
25
19
  };
26
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
21
  function transformBlock(block) {
28
- if (block.id.startsWith('builder-pixel-') && !block.component) {
22
+ if (block.id.startsWith("builder-pixel-") && !block.component) {
29
23
  return __spreadProps(__spreadValues({}, block), {
30
24
  component: {
31
- name: 'Image',
25
+ name: "Image",
32
26
  options: {
33
27
  image: block.properties.src,
34
28
  width: 1,
35
- height: 1,
36
- },
37
- },
29
+ height: 1
30
+ }
31
+ }
38
32
  });
39
33
  }
40
34
  return block;
41
35
  }
42
- export { transformBlock };
36
+ export {
37
+ transformBlock
38
+ };
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { default as default2 } from "../blocks/columns";
3
+ import { default as default3 } from "../blocks/image";
4
+ import { default as default4 } from "../blocks/text";
5
+ import { default as default5 } from "../blocks/symbol";
6
+ import { default as default6 } from "../blocks/button";
7
+ import { default as default7 } from "../blocks/section";
8
+ import { default as default8 } from "../blocks/fragment";
9
+ import { default as default9 } from "../components/render-content";
10
+ export {
11
+ default6 as Button,
12
+ default2 as Columns,
13
+ default8 as Fragment,
14
+ default3 as Image,
15
+ default9 as RenderContent,
16
+ default7 as Section,
17
+ default5 as Symbol,
18
+ default4 as Text
19
+ };
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ import "react-native-url-polyfill/auto";
package/src/index.js CHANGED
@@ -1,29 +1,14 @@
1
1
  import * as React from 'react';
2
- import 'react-native-url-polyfill/auto';
3
- import { isEditing } from './functions/is-editing';
2
+ import("./index-helpers/top-of-file");
3
+ import { isEditing } from "./functions/is-editing";
4
4
  if (isEditing()) {
5
- import('./scripts/init-editing');
5
+ import("./scripts/init-editing");
6
6
  }
7
- import { default as default2 } from './blocks/columns';
8
- import { default as default3 } from './blocks/image';
9
- import { default as default4 } from './blocks/text';
10
- import { default as default5 } from './blocks/symbol';
11
- import { default as default6 } from './blocks/section';
12
- import { default as default7 } from './blocks/fragment';
13
- import { default as default8 } from './components/render-content';
14
- import { default as default9 } from './blocks/button';
15
- export * from './functions/is-editing';
16
- export * from './functions/register-component';
17
- export * from './functions/register';
18
- export * from './functions/set-editor-settings';
19
- export * from './functions/get-content';
20
- export {
21
- default9 as Button,
22
- default2 as Columns,
23
- default7 as Fragment,
24
- default3 as Image,
25
- default8 as RenderContent,
26
- default6 as Section,
27
- default5 as Symbol,
28
- default4 as Text,
29
- };
7
+ export * from "./index-helpers/blocks-exports";
8
+ export * from "./functions/is-editing";
9
+ export * from "./functions/is-previewing";
10
+ export * from "./functions/register-component";
11
+ export * from "./functions/register";
12
+ export * from "./functions/set-editor-settings";
13
+ export * from "./functions/get-content";
14
+ export * from "./functions/get-builder-search-params";
@@ -1,43 +1,36 @@
1
1
  import * as React from 'react';
2
2
  var _a;
3
- import { isBrowser } from '../functions/is-browser';
4
- import { register } from '../functions/register';
5
- register('insertMenu', {
6
- name: '_default',
3
+ import { isBrowser } from "../functions/is-browser";
4
+ import { register } from "../functions/register";
5
+ register("insertMenu", {
6
+ name: "_default",
7
7
  default: true,
8
8
  items: [
9
- { name: 'Box' },
10
- { name: 'Text' },
11
- { name: 'Image' },
12
- { name: 'Columns' },
13
- ...(true
14
- ? []
15
- : [
16
- { name: 'Core:Section' },
17
- { name: 'Core:Button' },
18
- { name: 'Embed' },
19
- { name: 'Custom Code' },
20
- ]),
21
- ],
9
+ { name: "Box" },
10
+ { name: "Text" },
11
+ { name: "Image" },
12
+ { name: "Columns" },
13
+ ...true ? [] : [
14
+ { name: "Core:Section" },
15
+ { name: "Core:Button" },
16
+ { name: "Embed" },
17
+ { name: "Custom Code" }
18
+ ]
19
+ ]
22
20
  });
23
21
  if (isBrowser()) {
24
- (_a = window.parent) == null
25
- ? void 0
26
- : _a.postMessage(
27
- {
28
- type: 'builder.sdkInfo',
29
- data: {
30
- target: 'reactNative',
31
- supportsPatchUpdates: false,
32
- },
33
- },
34
- '*'
35
- );
36
- window.addEventListener('message', ({ data }) => {
22
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
23
+ type: "builder.sdkInfo",
24
+ data: {
25
+ target: "reactNative",
26
+ supportsPatchUpdates: false
27
+ }
28
+ }, "*");
29
+ window.addEventListener("message", ({ data }) => {
37
30
  var _a2, _b;
38
31
  if (data) {
39
32
  switch (data.type) {
40
- case 'builder.evaluate': {
33
+ case "builder.evaluate": {
41
34
  const text = data.data.text;
42
35
  const args = data.data.arguments || [];
43
36
  const id = data.data.id;
@@ -50,41 +43,24 @@ if (isBrowser()) {
50
43
  error = err;
51
44
  }
52
45
  if (error) {
53
- (_a2 = window.parent) == null
54
- ? void 0
55
- : _a2.postMessage(
56
- {
57
- type: 'builder.evaluateError',
58
- data: { id, error: error.message },
59
- },
60
- '*'
61
- );
46
+ (_a2 = window.parent) == null ? void 0 : _a2.postMessage({
47
+ type: "builder.evaluateError",
48
+ data: { id, error: error.message }
49
+ }, "*");
62
50
  } else {
63
- if (result && typeof result.then === 'function') {
64
- result
65
- .then((finalResult) => {
66
- var _a3;
67
- (_a3 = window.parent) == null
68
- ? void 0
69
- : _a3.postMessage(
70
- {
71
- type: 'builder.evaluateResult',
72
- data: { id, result: finalResult },
73
- },
74
- '*'
75
- );
76
- })
77
- .catch(console.error);
51
+ if (result && typeof result.then === "function") {
52
+ result.then((finalResult) => {
53
+ var _a3;
54
+ (_a3 = window.parent) == null ? void 0 : _a3.postMessage({
55
+ type: "builder.evaluateResult",
56
+ data: { id, result: finalResult }
57
+ }, "*");
58
+ }).catch(console.error);
78
59
  } else {
79
- (_b = window.parent) == null
80
- ? void 0
81
- : _b.postMessage(
82
- {
83
- type: 'builder.evaluateResult',
84
- data: { result, id },
85
- },
86
- '*'
87
- );
60
+ (_b = window.parent) == null ? void 0 : _b.postMessage({
61
+ type: "builder.evaluateResult",
62
+ data: { result, id }
63
+ }, "*");
88
64
  }
89
65
  }
90
66
  break;
@@ -0,0 +1 @@
1
+ import * as React from 'react';
@@ -1,152 +0,0 @@
1
- import * as React from 'react';
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) =>
9
- key in obj
10
- ? __defProp(obj, key, {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value,
15
- })
16
- : (obj[key] = value);
17
- var __spreadValues = (a, b) => {
18
- for (var prop in b || (b = {}))
19
- if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
20
- if (__getOwnPropSymbols)
21
- for (var prop of __getOwnPropSymbols(b)) {
22
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
23
- }
24
- return a;
25
- };
26
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
- var __async = (__this, __arguments, generator) => {
28
- return new Promise((resolve, reject) => {
29
- var fulfilled = (value) => {
30
- try {
31
- step(generator.next(value));
32
- } catch (e) {
33
- reject(e);
34
- }
35
- };
36
- var rejected = (value) => {
37
- try {
38
- step(generator.throw(value));
39
- } catch (e) {
40
- reject(e);
41
- }
42
- };
43
- var step = (x) =>
44
- x.done
45
- ? resolve(x.value)
46
- : Promise.resolve(x.value).then(fulfilled, rejected);
47
- step((generator = generator.apply(__this, __arguments)).next());
48
- });
49
- };
50
- import { getFetch } from './get-fetch';
51
- const fetch = getFetch();
52
- function flatten(object, path = null, separator = '.') {
53
- return Object.keys(object).reduce((acc, key) => {
54
- const value = object[key];
55
- const newPath = [path, key].filter(Boolean).join(separator);
56
- const isObject = [
57
- typeof value === 'object',
58
- value !== null,
59
- !(Array.isArray(value) && value.length === 0),
60
- ].every(Boolean);
61
- return isObject
62
- ? __spreadValues(
63
- __spreadValues({}, acc),
64
- flatten(value, newPath, separator)
65
- )
66
- : __spreadProps(__spreadValues({}, acc), { [newPath]: value });
67
- }, {});
68
- }
69
- function getContent(options) {
70
- return __async(this, null, function* () {
71
- return (
72
- (yield getAllContent(
73
- __spreadProps(__spreadValues({}, options), { limit: 1 })
74
- )).results[0] || null
75
- );
76
- });
77
- }
78
- function getAllContent(options) {
79
- return __async(this, null, function* () {
80
- const { model, apiKey } = options;
81
- const { limit, testGroups, userAttributes, query, noTraverse } =
82
- __spreadValues(
83
- {
84
- limit: 1,
85
- userAttributes: null,
86
- testGroups: null,
87
- noTraverse: false,
88
- },
89
- options
90
- );
91
- const url = new URL(
92
- `https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}`
93
- );
94
- if (options.options) {
95
- const flattened = flatten(options.options);
96
- for (const key in flattened) {
97
- url.searchParams.set(key, String(flattened[key]));
98
- }
99
- }
100
- if (userAttributes) {
101
- url.searchParams.set('userAttributes', JSON.stringify(userAttributes));
102
- }
103
- if (query) {
104
- const flattened = flatten({ query });
105
- for (const key in flattened) {
106
- url.searchParams.set(key, JSON.stringify(flattened[key]));
107
- }
108
- }
109
- const content = yield fetch(url.href).then((res) => res.json());
110
- if (testGroups) {
111
- for (const item of content.results) {
112
- if (item.variations && Object.keys(item.variations).length) {
113
- const testGroup = testGroups[item.id];
114
- const variationValue = item.variations[testGroup];
115
- if (testGroup && variationValue) {
116
- item.data = variationValue.data;
117
- item.testVariationId = variationValue.id;
118
- item.testVariationName = variationValue.name;
119
- } else {
120
- let n = 0;
121
- const random = Math.random();
122
- let set = false;
123
- for (const id in item.variations) {
124
- const variation = item.variations[id];
125
- const testRatio = variation.testRatio;
126
- n += testRatio;
127
- if (random < n) {
128
- const variationName =
129
- variation.name ||
130
- (variation.id === item.id ? 'Default variation' : '');
131
- set = true;
132
- Object.assign(item, {
133
- data: variation.data,
134
- testVariationId: variation.id,
135
- testVariationName: variationName,
136
- });
137
- }
138
- }
139
- if (!set) {
140
- Object.assign(item, {
141
- testVariationId: item.id,
142
- testVariationName: 'Default',
143
- });
144
- }
145
- }
146
- }
147
- }
148
- }
149
- return content;
150
- });
151
- }
152
- export { getAllContent, getContent };
@@ -1,58 +0,0 @@
1
- import * as React from 'react';
2
- var __async = (__this, __arguments, generator) => {
3
- return new Promise((resolve, reject) => {
4
- var fulfilled = (value) => {
5
- try {
6
- step(generator.next(value));
7
- } catch (e) {
8
- reject(e);
9
- }
10
- };
11
- var rejected = (value) => {
12
- try {
13
- step(generator.throw(value));
14
- } catch (e) {
15
- reject(e);
16
- }
17
- };
18
- var step = (x) =>
19
- x.done
20
- ? resolve(x.value)
21
- : Promise.resolve(x.value).then(fulfilled, rejected);
22
- step((generator = generator.apply(__this, __arguments)).next());
23
- });
24
- };
25
- import fetchMock from 'jest-fetch-mock';
26
- fetchMock.enableMocks();
27
- import { test, beforeEach, expect } from '@jest/globals';
28
- import { getContent } from './get-content';
29
- const testKey = 'YJIGb4i01jvw0SRdL5Bt';
30
- const testModel = 'page';
31
- const testId = 'c1b81bab59704599b997574eb0736def';
32
- beforeEach(() => {});
33
- test.skip('Get content', () =>
34
- __async(void 0, null, function* () {
35
- var _a, _b;
36
- expect(
37
- (_a = yield getContent({
38
- apiKey: testKey,
39
- model: testModel,
40
- query: {
41
- id: testId,
42
- },
43
- })) == null
44
- ? void 0
45
- : _a.id
46
- ).toEqual(testId);
47
- expect(
48
- (_b = yield getContent({
49
- apiKey: testKey,
50
- model: testModel,
51
- userAttributes: {
52
- urlPath: '/test-page',
53
- },
54
- })) == null
55
- ? void 0
56
- : _b.id
57
- ).toEqual(testId);
58
- }));