@constructor-io/constructorio-connect-cli 1.15.0 → 1.15.2

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.
@@ -1,10 +1,18 @@
1
1
  /**
2
2
  * Check out the documentation to see how to write and maintain tests:
3
3
  * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
- */
4
+ */
5
+
6
+ import { executeTemplate, buildFixture } from "@constructor-io/constructorio-connect-cli";
5
7
 
6
8
  describe("item", () => {
7
- it("should be defined", async () => {
8
- expect(true).toBe(true);
9
+ it("should match snapshot", async () => {
10
+ const result = await executeTemplate({
11
+ type: "item",
12
+ name: "item.jsonata",
13
+ fixture: buildFixture("item", "item.json"),
14
+ });
15
+
16
+ expect(result).toMatchSnapshot();
9
17
  });
10
18
  });
@@ -1,10 +1,18 @@
1
1
  /**
2
2
  * Check out the documentation to see how to write and maintain tests:
3
3
  * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
- */
4
+ */
5
+
6
+ import { executeTemplate, buildFixture } from "@constructor-io/constructorio-connect-cli";
5
7
 
6
8
  describe("item_group", () => {
7
- it("should be defined", async () => {
8
- expect(true).toBe(true);
9
+ it("should match snapshot", async () => {
10
+ const result = await executeTemplate({
11
+ type: "item_group",
12
+ name: "item_group.jsonata",
13
+ fixture: buildFixture("item_group", "item_group.json"),
14
+ });
15
+
16
+ expect(result).toMatchSnapshot();
9
17
  });
10
18
  });
@@ -1,10 +1,38 @@
1
1
  /**
2
2
  * Check out the documentation to see how to write and maintain tests:
3
3
  * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
- */
4
+ */
5
+
6
+ import { executeTemplate, buildFixture } from "@constructor-io/constructorio-connect-cli";
5
7
 
6
8
  describe("mapping", () => {
7
- it("should be defined", async () => {
8
- expect(true).toBe(true);
9
+ it("should map item groups", async () => {
10
+ const result = await executeTemplate({
11
+ type: "mapping",
12
+ name: "mapping.jsonata",
13
+ fixture: buildFixture("mapping", "mapping.json"),
14
+ });
15
+
16
+ expect(result.item_groups).toMatchSnapshot();
17
+ });
18
+
19
+ it("should map items", async () => {
20
+ const result = await executeTemplate({
21
+ type: "mapping",
22
+ name: "mapping.jsonata",
23
+ fixture: buildFixture("mapping", "mapping.json"),
24
+ });
25
+
26
+ expect(result.items).toMatchSnapshot();
27
+ });
28
+
29
+ it("should map variations", async () => {
30
+ const result = await executeTemplate({
31
+ type: "mapping",
32
+ name: "mapping.jsonata",
33
+ fixture: buildFixture("mapping", "mapping.json"),
34
+ });
35
+
36
+ expect(result.variations).toMatchSnapshot();
9
37
  });
10
38
  });
@@ -1,10 +1,18 @@
1
1
  /**
2
2
  * Check out the documentation to see how to write and maintain tests:
3
3
  * @see https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-development-flow#step-3-test-your-templates
4
- */
4
+ */
5
+
6
+ import { executeTemplate, buildFixture } from "@constructor-io/constructorio-connect-cli";
5
7
 
6
8
  describe("variation", () => {
7
- it("should be defined", async () => {
8
- expect(true).toBe(true);
9
+ it("should match snapshot", async () => {
10
+ const result = await executeTemplate({
11
+ type: "variation",
12
+ name: "variation.jsonata",
13
+ fixture: buildFixture("variation", "variation.json"),
14
+ });
15
+
16
+ expect(result).toMatchSnapshot();
9
17
  });
10
18
  });
@@ -7,7 +7,7 @@
7
7
  * @param type string The type of fixture
8
8
  * @param name string The name/path of the fixture
9
9
  * @param dataOverride string The data to override in the fixture
10
- * @returns Record<string, unknown> The fixture data
10
+ * @returns Record<string, unknown> or Array<Record<string, unknown>> The fixture data
11
11
  */
12
- export declare const buildFixture: (type: string, name: string, dataOverride?: Record<string, unknown>) => never;
12
+ export declare const buildFixture: (type: string, name: string, dataOverride?: Record<string, unknown>) => never[];
13
13
  //# sourceMappingURL=build-fixture.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-fixture.d.ts","sourceRoot":"","sources":["../../src/functions/build-fixture.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,eAAc,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,UAK3C,CAAC"}
1
+ {"version":3,"file":"build-fixture.d.ts","sourceRoot":"","sources":["../../src/functions/build-fixture.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,eAAc,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,YAW3C,CAAC"}
@@ -16,10 +16,15 @@ const file_loaders_1 = require("../helpers/file-loaders");
16
16
  * @param type string The type of fixture
17
17
  * @param name string The name/path of the fixture
18
18
  * @param dataOverride string The data to override in the fixture
19
- * @returns Record<string, unknown> The fixture data
19
+ * @returns Record<string, unknown> or Array<Record<string, unknown>> The fixture data
20
20
  */
21
21
  const buildFixture = (type, name, dataOverride = {}) => {
22
22
  const data = (0, file_loaders_1.getCatalogFixture)(path_1.default.join(type, name));
23
+ if (Array.isArray(data)) {
24
+ return data.map((item) => {
25
+ return (0, remeda_1.mergeDeep)(item, dataOverride);
26
+ });
27
+ }
23
28
  return (0, remeda_1.mergeDeep)(data, dataOverride);
24
29
  };
25
30
  exports.buildFixture = buildFixture;
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const _default: "1.15.0";
1
+ declare const _default: "1.15.2";
2
2
  export default _default;
3
3
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.15.0';
3
+ exports.default = '1.15.2';
@@ -199,5 +199,5 @@
199
199
  ]
200
200
  }
201
201
  },
202
- "version": "1.15.0"
202
+ "version": "1.15.2"
203
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-connect-cli",
3
- "version": "1.15.0",
3
+ "version": "1.15.2",
4
4
  "description": "CLI tool to enable users to interface with the Constructor Connect Ecosystem",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",