@powerhousedao/vetra 5.1.0-dev.20 → 5.1.0-dev.21
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.
- package/dist/document-models/app-module/src/tests/base-operations.test.js +52 -1
- package/dist/document-models/document-editor/src/tests/base-operations.test.js +42 -1
- package/dist/document-models/processor-module/src/tests/base-operations.test.js +52 -1
- package/dist/document-models/subgraph-module/src/tests/base-operations.test.js +22 -1
- package/dist/document-models/vetra-package/src/tests/base-operations.test.js +127 -28
- package/dist/processors/codegen/__tests__/codegen-processor-e2e.test.js +53 -41
- package/dist/processors/codegen/document-handlers/generators/app-generator.js +2 -2
- package/dist/processors/codegen/document-handlers/generators/constants.d.ts +1 -1
- package/dist/processors/codegen/document-handlers/generators/constants.d.ts.map +1 -1
- package/dist/processors/codegen/document-handlers/generators/constants.js +1 -1
- package/dist/processors/codegen/document-handlers/generators/document-editor-generator.js +2 -2
- package/dist/processors/codegen/document-handlers/generators/document-model-generator.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* This is a scaffold file meant for customization:
|
|
3
3
|
* - change it by adding new tests or modifying the existing ones
|
|
4
4
|
*/
|
|
5
|
-
import { addDocumentType, reducer, removeDocumentType, setAppName, setAppStatus, utils, } from "@powerhousedao/vetra/document-models/app-module";
|
|
5
|
+
import { addDocumentType, reducer, removeDocumentType, setAppName, setAppStatus, utils, isAppModuleDocument, setDocumentTypes, SetAppNameInputSchema, SetAppStatusInputSchema, AddDocumentTypeInputSchema, RemoveDocumentTypeInputSchema, SetDocumentTypesInputSchema, } from "@powerhousedao/vetra/document-models/app-module";
|
|
6
6
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
7
|
+
import { generateMock } from "@powerhousedao/codegen";
|
|
7
8
|
describe("BaseOperations Operations", () => {
|
|
8
9
|
let document;
|
|
9
10
|
beforeEach(() => {
|
|
@@ -170,4 +171,54 @@ describe("BaseOperations Operations", () => {
|
|
|
170
171
|
expect(updatedDoc.state.global.allowedDocumentTypes).not.toContain("powerhouse/b");
|
|
171
172
|
});
|
|
172
173
|
});
|
|
174
|
+
it("should handle setAppName operation", () => {
|
|
175
|
+
const document = utils.createDocument();
|
|
176
|
+
const input = generateMock(SetAppNameInputSchema());
|
|
177
|
+
const updatedDocument = reducer(document, setAppName(input));
|
|
178
|
+
expect(isAppModuleDocument(updatedDocument)).toBe(true);
|
|
179
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
180
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_APP_NAME");
|
|
181
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
182
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
183
|
+
});
|
|
184
|
+
it("should handle setAppStatus operation", () => {
|
|
185
|
+
const document = utils.createDocument();
|
|
186
|
+
const input = generateMock(SetAppStatusInputSchema());
|
|
187
|
+
const updatedDocument = reducer(document, setAppStatus(input));
|
|
188
|
+
expect(isAppModuleDocument(updatedDocument)).toBe(true);
|
|
189
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
190
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_APP_STATUS");
|
|
191
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
192
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
193
|
+
});
|
|
194
|
+
it("should handle addDocumentType operation", () => {
|
|
195
|
+
const document = utils.createDocument();
|
|
196
|
+
const input = generateMock(AddDocumentTypeInputSchema());
|
|
197
|
+
const updatedDocument = reducer(document, addDocumentType(input));
|
|
198
|
+
expect(isAppModuleDocument(updatedDocument)).toBe(true);
|
|
199
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
200
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("ADD_DOCUMENT_TYPE");
|
|
201
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
202
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
203
|
+
});
|
|
204
|
+
it("should handle removeDocumentType operation", () => {
|
|
205
|
+
const document = utils.createDocument();
|
|
206
|
+
const input = generateMock(RemoveDocumentTypeInputSchema());
|
|
207
|
+
const updatedDocument = reducer(document, removeDocumentType(input));
|
|
208
|
+
expect(isAppModuleDocument(updatedDocument)).toBe(true);
|
|
209
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
210
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("REMOVE_DOCUMENT_TYPE");
|
|
211
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
212
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
213
|
+
});
|
|
214
|
+
it("should handle setDocumentTypes operation", () => {
|
|
215
|
+
const document = utils.createDocument();
|
|
216
|
+
const input = generateMock(SetDocumentTypesInputSchema());
|
|
217
|
+
const updatedDocument = reducer(document, setDocumentTypes(input));
|
|
218
|
+
expect(isAppModuleDocument(updatedDocument)).toBe(true);
|
|
219
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
220
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_DOCUMENT_TYPES");
|
|
221
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
222
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
223
|
+
});
|
|
173
224
|
});
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* This is a scaffold file meant for customization:
|
|
3
3
|
* - change it by adding new tests or modifying the existing ones
|
|
4
4
|
*/
|
|
5
|
-
import { addDocumentType, reducer, removeDocumentType, setEditorName, setEditorStatus, utils, } from "@powerhousedao/vetra/document-models/document-editor";
|
|
5
|
+
import { addDocumentType, reducer, removeDocumentType, setEditorName, setEditorStatus, utils, isDocumentEditorDocument, SetEditorNameInputSchema, AddDocumentTypeInputSchema, RemoveDocumentTypeInputSchema, SetEditorStatusInputSchema, } from "@powerhousedao/vetra/document-models/document-editor";
|
|
6
6
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
7
|
+
import { generateMock } from "@powerhousedao/codegen";
|
|
7
8
|
describe("BaseOperations Operations", () => {
|
|
8
9
|
let document;
|
|
9
10
|
beforeEach(() => {
|
|
@@ -149,4 +150,44 @@ describe("BaseOperations Operations", () => {
|
|
|
149
150
|
expect(updatedDoc.operations.global).toHaveLength(2);
|
|
150
151
|
});
|
|
151
152
|
});
|
|
153
|
+
it("should handle setEditorName operation", () => {
|
|
154
|
+
const document = utils.createDocument();
|
|
155
|
+
const input = generateMock(SetEditorNameInputSchema());
|
|
156
|
+
const updatedDocument = reducer(document, setEditorName(input));
|
|
157
|
+
expect(isDocumentEditorDocument(updatedDocument)).toBe(true);
|
|
158
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
159
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_EDITOR_NAME");
|
|
160
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
161
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
162
|
+
});
|
|
163
|
+
it("should handle addDocumentType operation", () => {
|
|
164
|
+
const document = utils.createDocument();
|
|
165
|
+
const input = generateMock(AddDocumentTypeInputSchema());
|
|
166
|
+
const updatedDocument = reducer(document, addDocumentType(input));
|
|
167
|
+
expect(isDocumentEditorDocument(updatedDocument)).toBe(true);
|
|
168
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
169
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("ADD_DOCUMENT_TYPE");
|
|
170
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
171
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
172
|
+
});
|
|
173
|
+
it("should handle removeDocumentType operation", () => {
|
|
174
|
+
const document = utils.createDocument();
|
|
175
|
+
const input = generateMock(RemoveDocumentTypeInputSchema());
|
|
176
|
+
const updatedDocument = reducer(document, removeDocumentType(input));
|
|
177
|
+
expect(isDocumentEditorDocument(updatedDocument)).toBe(true);
|
|
178
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
179
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("REMOVE_DOCUMENT_TYPE");
|
|
180
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
181
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
182
|
+
});
|
|
183
|
+
it("should handle setEditorStatus operation", () => {
|
|
184
|
+
const document = utils.createDocument();
|
|
185
|
+
const input = generateMock(SetEditorStatusInputSchema());
|
|
186
|
+
const updatedDocument = reducer(document, setEditorStatus(input));
|
|
187
|
+
expect(isDocumentEditorDocument(updatedDocument)).toBe(true);
|
|
188
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
189
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_EDITOR_STATUS");
|
|
190
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
191
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
192
|
+
});
|
|
152
193
|
});
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* This is a scaffold file meant for customization:
|
|
3
3
|
* - change it by adding new tests or modifying the existing ones
|
|
4
4
|
*/
|
|
5
|
-
import { addDocumentType, reducer, removeDocumentType, setProcessorName, setProcessorStatus, setProcessorType, utils, } from "@powerhousedao/vetra/document-models/processor-module";
|
|
5
|
+
import { addDocumentType, reducer, removeDocumentType, setProcessorName, setProcessorStatus, setProcessorType, utils, isProcessorModuleDocument, SetProcessorNameInputSchema, SetProcessorTypeInputSchema, AddDocumentTypeInputSchema, RemoveDocumentTypeInputSchema, SetProcessorStatusInputSchema, } from "@powerhousedao/vetra/document-models/processor-module";
|
|
6
6
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
7
|
+
import { generateMock } from "@powerhousedao/codegen";
|
|
7
8
|
describe("BaseOperations Operations", () => {
|
|
8
9
|
let document;
|
|
9
10
|
beforeEach(() => {
|
|
@@ -163,4 +164,54 @@ describe("BaseOperations Operations", () => {
|
|
|
163
164
|
expect(updatedDoc.operations.global).toHaveLength(2);
|
|
164
165
|
});
|
|
165
166
|
});
|
|
167
|
+
it("should handle setProcessorName operation", () => {
|
|
168
|
+
const document = utils.createDocument();
|
|
169
|
+
const input = generateMock(SetProcessorNameInputSchema());
|
|
170
|
+
const updatedDocument = reducer(document, setProcessorName(input));
|
|
171
|
+
expect(isProcessorModuleDocument(updatedDocument)).toBe(true);
|
|
172
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
173
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PROCESSOR_NAME");
|
|
174
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
175
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
176
|
+
});
|
|
177
|
+
it("should handle setProcessorType operation", () => {
|
|
178
|
+
const document = utils.createDocument();
|
|
179
|
+
const input = generateMock(SetProcessorTypeInputSchema());
|
|
180
|
+
const updatedDocument = reducer(document, setProcessorType(input));
|
|
181
|
+
expect(isProcessorModuleDocument(updatedDocument)).toBe(true);
|
|
182
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
183
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PROCESSOR_TYPE");
|
|
184
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
185
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
186
|
+
});
|
|
187
|
+
it("should handle addDocumentType operation", () => {
|
|
188
|
+
const document = utils.createDocument();
|
|
189
|
+
const input = generateMock(AddDocumentTypeInputSchema());
|
|
190
|
+
const updatedDocument = reducer(document, addDocumentType(input));
|
|
191
|
+
expect(isProcessorModuleDocument(updatedDocument)).toBe(true);
|
|
192
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
193
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("ADD_DOCUMENT_TYPE");
|
|
194
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
195
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
196
|
+
});
|
|
197
|
+
it("should handle removeDocumentType operation", () => {
|
|
198
|
+
const document = utils.createDocument();
|
|
199
|
+
const input = generateMock(RemoveDocumentTypeInputSchema());
|
|
200
|
+
const updatedDocument = reducer(document, removeDocumentType(input));
|
|
201
|
+
expect(isProcessorModuleDocument(updatedDocument)).toBe(true);
|
|
202
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
203
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("REMOVE_DOCUMENT_TYPE");
|
|
204
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
205
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
206
|
+
});
|
|
207
|
+
it("should handle setProcessorStatus operation", () => {
|
|
208
|
+
const document = utils.createDocument();
|
|
209
|
+
const input = generateMock(SetProcessorStatusInputSchema());
|
|
210
|
+
const updatedDocument = reducer(document, setProcessorStatus(input));
|
|
211
|
+
expect(isProcessorModuleDocument(updatedDocument)).toBe(true);
|
|
212
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
213
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PROCESSOR_STATUS");
|
|
214
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
215
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
216
|
+
});
|
|
166
217
|
});
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* This is a scaffold file meant for customization:
|
|
3
3
|
* - change it by adding new tests or modifying the existing ones
|
|
4
4
|
*/
|
|
5
|
-
import { reducer, setSubgraphName, setSubgraphStatus, utils, } from "@powerhousedao/vetra/document-models/subgraph-module";
|
|
5
|
+
import { reducer, setSubgraphName, setSubgraphStatus, utils, isSubgraphModuleDocument, SetSubgraphNameInputSchema, SetSubgraphStatusInputSchema, } from "@powerhousedao/vetra/document-models/subgraph-module";
|
|
6
6
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
7
|
+
import { generateMock } from "@powerhousedao/codegen";
|
|
7
8
|
describe("BaseOperations Operations", () => {
|
|
8
9
|
let document;
|
|
9
10
|
beforeEach(() => {
|
|
@@ -40,4 +41,24 @@ describe("BaseOperations Operations", () => {
|
|
|
40
41
|
expect(updatedDocument.state.global.status).toBe("DRAFT");
|
|
41
42
|
});
|
|
42
43
|
});
|
|
44
|
+
it("should handle setSubgraphName operation", () => {
|
|
45
|
+
const document = utils.createDocument();
|
|
46
|
+
const input = generateMock(SetSubgraphNameInputSchema());
|
|
47
|
+
const updatedDocument = reducer(document, setSubgraphName(input));
|
|
48
|
+
expect(isSubgraphModuleDocument(updatedDocument)).toBe(true);
|
|
49
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
50
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_SUBGRAPH_NAME");
|
|
51
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
52
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
53
|
+
});
|
|
54
|
+
it("should handle setSubgraphStatus operation", () => {
|
|
55
|
+
const document = utils.createDocument();
|
|
56
|
+
const input = generateMock(SetSubgraphStatusInputSchema());
|
|
57
|
+
const updatedDocument = reducer(document, setSubgraphStatus(input));
|
|
58
|
+
expect(isSubgraphModuleDocument(updatedDocument)).toBe(true);
|
|
59
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
60
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_SUBGRAPH_STATUS");
|
|
61
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
62
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
63
|
+
});
|
|
43
64
|
});
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* This is a scaffold file meant for customization:
|
|
3
3
|
* - change it by adding new tests or modifying the existing ones
|
|
4
4
|
*/
|
|
5
|
+
import { generateMock } from "@powerhousedao/codegen";
|
|
6
|
+
import { addPackageKeyword, AddPackageKeywordInputSchema, isVetraPackageDocument, reducer, removePackageKeyword, RemovePackageKeywordInputSchema, setPackageAuthor, SetPackageAuthorInputSchema, setPackageAuthorName, SetPackageAuthorNameInputSchema, setPackageAuthorWebsite, SetPackageAuthorWebsiteInputSchema, setPackageCategory, SetPackageCategoryInputSchema, setPackageDescription, SetPackageDescriptionInputSchema, setPackageGithubUrl, SetPackageGithubUrlInputSchema, setPackageName, SetPackageNameInputSchema, setPackageNpmUrl, SetPackageNpmUrlInputSchema, utils, } from "@powerhousedao/vetra/document-models/vetra-package";
|
|
5
7
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
6
|
-
import * as creators from "../../gen/base-operations/creators.js";
|
|
7
|
-
import { reducer } from "../../gen/reducer.js";
|
|
8
|
-
import { utils } from "@powerhousedao/vetra/document-models/vetra-package";
|
|
9
8
|
describe("BaseOperations Operations", () => {
|
|
10
9
|
let document;
|
|
11
10
|
beforeEach(() => {
|
|
@@ -14,7 +13,7 @@ describe("BaseOperations Operations", () => {
|
|
|
14
13
|
describe("setPackageName", () => {
|
|
15
14
|
it("should mutate state with new name", () => {
|
|
16
15
|
const input = { name: "my-package" };
|
|
17
|
-
const updatedDocument = reducer(document,
|
|
16
|
+
const updatedDocument = reducer(document, setPackageName(input));
|
|
18
17
|
expect(updatedDocument.state.global.name).toBe("my-package");
|
|
19
18
|
});
|
|
20
19
|
});
|
|
@@ -23,14 +22,14 @@ describe("BaseOperations Operations", () => {
|
|
|
23
22
|
const input = {
|
|
24
23
|
description: "A test package",
|
|
25
24
|
};
|
|
26
|
-
const updatedDocument = reducer(document,
|
|
25
|
+
const updatedDocument = reducer(document, setPackageDescription(input));
|
|
27
26
|
expect(updatedDocument.state.global.description).toBe("A test package");
|
|
28
27
|
});
|
|
29
28
|
});
|
|
30
29
|
describe("setPackageCategory", () => {
|
|
31
30
|
it("should mutate state with new category", () => {
|
|
32
31
|
const input = { category: "utility" };
|
|
33
|
-
const updatedDocument = reducer(document,
|
|
32
|
+
const updatedDocument = reducer(document, setPackageCategory(input));
|
|
34
33
|
expect(updatedDocument.state.global.category).toBe("utility");
|
|
35
34
|
});
|
|
36
35
|
});
|
|
@@ -40,17 +39,17 @@ describe("BaseOperations Operations", () => {
|
|
|
40
39
|
name: "John Doe",
|
|
41
40
|
website: "https://johndoe.com",
|
|
42
41
|
};
|
|
43
|
-
const updatedDocument = reducer(document,
|
|
42
|
+
const updatedDocument = reducer(document, setPackageAuthor(input));
|
|
44
43
|
expect(updatedDocument.state.global.author.name).toBe("John Doe");
|
|
45
44
|
expect(updatedDocument.state.global.author.website).toBe("https://johndoe.com");
|
|
46
45
|
});
|
|
47
46
|
it("should handle partial author data (name only or website only)", () => {
|
|
48
47
|
// Name only
|
|
49
|
-
let updatedDoc = reducer(document,
|
|
48
|
+
let updatedDoc = reducer(document, setPackageAuthor({ name: "Jane Doe" }));
|
|
50
49
|
expect(updatedDoc.state.global.author.name).toBe("Jane Doe");
|
|
51
50
|
expect(updatedDoc.state.global.author.website).toBeNull();
|
|
52
51
|
// Website only
|
|
53
|
-
updatedDoc = reducer(updatedDoc,
|
|
52
|
+
updatedDoc = reducer(updatedDoc, setPackageAuthor({ website: "https://janedoe.com" }));
|
|
54
53
|
expect(updatedDoc.state.global.author.name).toBeNull();
|
|
55
54
|
expect(updatedDoc.state.global.author.website).toBe("https://janedoe.com");
|
|
56
55
|
});
|
|
@@ -58,7 +57,7 @@ describe("BaseOperations Operations", () => {
|
|
|
58
57
|
describe("setPackageAuthorName", () => {
|
|
59
58
|
it("should mutate state with new author name", () => {
|
|
60
59
|
const input = { name: "Alice" };
|
|
61
|
-
const updatedDocument = reducer(document,
|
|
60
|
+
const updatedDocument = reducer(document, setPackageAuthorName(input));
|
|
62
61
|
expect(updatedDocument.state.global.author.name).toBe("Alice");
|
|
63
62
|
});
|
|
64
63
|
});
|
|
@@ -67,7 +66,7 @@ describe("BaseOperations Operations", () => {
|
|
|
67
66
|
const input = {
|
|
68
67
|
website: "https://example.com",
|
|
69
68
|
};
|
|
70
|
-
const updatedDocument = reducer(document,
|
|
69
|
+
const updatedDocument = reducer(document, setPackageAuthorWebsite(input));
|
|
71
70
|
expect(updatedDocument.state.global.author.website).toBe("https://example.com");
|
|
72
71
|
});
|
|
73
72
|
});
|
|
@@ -77,7 +76,7 @@ describe("BaseOperations Operations", () => {
|
|
|
77
76
|
id: "kw-1",
|
|
78
77
|
label: "react",
|
|
79
78
|
};
|
|
80
|
-
const updatedDocument = reducer(document,
|
|
79
|
+
const updatedDocument = reducer(document, addPackageKeyword(input));
|
|
81
80
|
expect(updatedDocument.state.global.keywords).toContainEqual({
|
|
82
81
|
id: "kw-1",
|
|
83
82
|
label: "react",
|
|
@@ -89,15 +88,15 @@ describe("BaseOperations Operations", () => {
|
|
|
89
88
|
id: "first-kw",
|
|
90
89
|
label: "typescript",
|
|
91
90
|
};
|
|
92
|
-
const updatedDocument = reducer(document,
|
|
91
|
+
const updatedDocument = reducer(document, addPackageKeyword(input));
|
|
93
92
|
expect(updatedDocument.state.global.keywords).toEqual([
|
|
94
93
|
{ id: "first-kw", label: "typescript" },
|
|
95
94
|
]);
|
|
96
95
|
});
|
|
97
96
|
it("should add multiple keywords sequentially", () => {
|
|
98
|
-
let updatedDoc = reducer(document,
|
|
99
|
-
updatedDoc = reducer(updatedDoc,
|
|
100
|
-
updatedDoc = reducer(updatedDoc,
|
|
97
|
+
let updatedDoc = reducer(document, addPackageKeyword({ id: "kw-1", label: "react" }));
|
|
98
|
+
updatedDoc = reducer(updatedDoc, addPackageKeyword({ id: "kw-2", label: "vue" }));
|
|
99
|
+
updatedDoc = reducer(updatedDoc, addPackageKeyword({ id: "kw-3", label: "angular" }));
|
|
101
100
|
expect(updatedDoc.state.global.keywords).toHaveLength(3);
|
|
102
101
|
expect(updatedDoc.state.global.keywords[0]).toEqual({
|
|
103
102
|
id: "kw-1",
|
|
@@ -117,10 +116,10 @@ describe("BaseOperations Operations", () => {
|
|
|
117
116
|
id: "duplicate",
|
|
118
117
|
label: "first",
|
|
119
118
|
};
|
|
120
|
-
let updatedDoc = reducer(document,
|
|
119
|
+
let updatedDoc = reducer(document, addPackageKeyword(input));
|
|
121
120
|
expect(updatedDoc.state.global.keywords).toHaveLength(1);
|
|
122
121
|
expect(updatedDoc.operations.global[0].error).toBeUndefined();
|
|
123
|
-
updatedDoc = reducer(updatedDoc,
|
|
122
|
+
updatedDoc = reducer(updatedDoc, addPackageKeyword({
|
|
124
123
|
id: "duplicate",
|
|
125
124
|
label: "second",
|
|
126
125
|
}));
|
|
@@ -131,42 +130,42 @@ describe("BaseOperations Operations", () => {
|
|
|
131
130
|
});
|
|
132
131
|
describe("removePackageKeyword", () => {
|
|
133
132
|
it("should mutate state by removing keyword from array", () => {
|
|
134
|
-
let updatedDoc = reducer(document,
|
|
133
|
+
let updatedDoc = reducer(document, addPackageKeyword({
|
|
135
134
|
id: "to-remove",
|
|
136
135
|
label: "test",
|
|
137
136
|
}));
|
|
138
|
-
updatedDoc = reducer(updatedDoc,
|
|
137
|
+
updatedDoc = reducer(updatedDoc, removePackageKeyword({ id: "to-remove" }));
|
|
139
138
|
expect(updatedDoc.state.global.keywords).not.toContainEqual({
|
|
140
139
|
id: "to-remove",
|
|
141
140
|
label: "test",
|
|
142
141
|
});
|
|
143
142
|
});
|
|
144
143
|
it("should remove existing ID", () => {
|
|
145
|
-
let updatedDoc = reducer(document,
|
|
144
|
+
let updatedDoc = reducer(document, addPackageKeyword({
|
|
146
145
|
id: "existing",
|
|
147
146
|
label: "test",
|
|
148
147
|
}));
|
|
149
148
|
const lengthBefore = updatedDoc.state.global.keywords.length;
|
|
150
|
-
updatedDoc = reducer(updatedDoc,
|
|
149
|
+
updatedDoc = reducer(updatedDoc, removePackageKeyword({ id: "existing" }));
|
|
151
150
|
expect(updatedDoc.state.global.keywords.length).toBe(lengthBefore - 1);
|
|
152
151
|
expect(updatedDoc.state.global.keywords.find((kw) => kw.id === "existing")).toBeUndefined();
|
|
153
152
|
});
|
|
154
153
|
it("should gracefully handle non-existent ID", () => {
|
|
155
154
|
const initialState = document.state.global.keywords;
|
|
156
|
-
const updatedDocument = reducer(document,
|
|
155
|
+
const updatedDocument = reducer(document, removePackageKeyword({ id: "non-existent-id" }));
|
|
157
156
|
expect(updatedDocument.state.global.keywords).toEqual(initialState);
|
|
158
157
|
});
|
|
159
158
|
it("should handle empty array gracefully", () => {
|
|
160
159
|
expect(document.state.global.keywords).toEqual([]);
|
|
161
|
-
const updatedDocument = reducer(document,
|
|
160
|
+
const updatedDocument = reducer(document, removePackageKeyword({ id: "any-id" }));
|
|
162
161
|
expect(updatedDocument.state.global.keywords).toEqual([]);
|
|
163
162
|
});
|
|
164
163
|
it("should add then immediately remove item", () => {
|
|
165
|
-
let updatedDoc = reducer(document,
|
|
164
|
+
let updatedDoc = reducer(document, addPackageKeyword({
|
|
166
165
|
id: "temp-kw",
|
|
167
166
|
label: "temp",
|
|
168
167
|
}));
|
|
169
|
-
updatedDoc = reducer(updatedDoc,
|
|
168
|
+
updatedDoc = reducer(updatedDoc, removePackageKeyword({ id: "temp-kw" }));
|
|
170
169
|
expect(updatedDoc.state.global.keywords.find((kw) => kw.id === "temp-kw")).toBeUndefined();
|
|
171
170
|
expect(updatedDoc.operations.global).toHaveLength(2);
|
|
172
171
|
});
|
|
@@ -176,7 +175,7 @@ describe("BaseOperations Operations", () => {
|
|
|
176
175
|
const input = {
|
|
177
176
|
url: "https://github.com/user/repo",
|
|
178
177
|
};
|
|
179
|
-
const updatedDocument = reducer(document,
|
|
178
|
+
const updatedDocument = reducer(document, setPackageGithubUrl(input));
|
|
180
179
|
expect(updatedDocument.state.global.githubUrl).toBe("https://github.com/user/repo");
|
|
181
180
|
});
|
|
182
181
|
});
|
|
@@ -185,8 +184,108 @@ describe("BaseOperations Operations", () => {
|
|
|
185
184
|
const input = {
|
|
186
185
|
url: "https://npmjs.com/package/my-package",
|
|
187
186
|
};
|
|
188
|
-
const updatedDocument = reducer(document,
|
|
187
|
+
const updatedDocument = reducer(document, setPackageNpmUrl(input));
|
|
189
188
|
expect(updatedDocument.state.global.npmUrl).toBe("https://npmjs.com/package/my-package");
|
|
190
189
|
});
|
|
191
190
|
});
|
|
191
|
+
it("should handle setPackageName operation", () => {
|
|
192
|
+
const document = utils.createDocument();
|
|
193
|
+
const input = generateMock(SetPackageNameInputSchema());
|
|
194
|
+
const updatedDocument = reducer(document, setPackageName(input));
|
|
195
|
+
expect(isVetraPackageDocument(updatedDocument)).toBe(true);
|
|
196
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
197
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PACKAGE_NAME");
|
|
198
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
199
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
200
|
+
});
|
|
201
|
+
it("should handle setPackageDescription operation", () => {
|
|
202
|
+
const document = utils.createDocument();
|
|
203
|
+
const input = generateMock(SetPackageDescriptionInputSchema());
|
|
204
|
+
const updatedDocument = reducer(document, setPackageDescription(input));
|
|
205
|
+
expect(isVetraPackageDocument(updatedDocument)).toBe(true);
|
|
206
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
207
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PACKAGE_DESCRIPTION");
|
|
208
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
209
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
210
|
+
});
|
|
211
|
+
it("should handle setPackageCategory operation", () => {
|
|
212
|
+
const document = utils.createDocument();
|
|
213
|
+
const input = generateMock(SetPackageCategoryInputSchema());
|
|
214
|
+
const updatedDocument = reducer(document, setPackageCategory(input));
|
|
215
|
+
expect(isVetraPackageDocument(updatedDocument)).toBe(true);
|
|
216
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
217
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PACKAGE_CATEGORY");
|
|
218
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
219
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
220
|
+
});
|
|
221
|
+
it("should handle setPackageAuthor operation", () => {
|
|
222
|
+
const document = utils.createDocument();
|
|
223
|
+
const input = generateMock(SetPackageAuthorInputSchema());
|
|
224
|
+
const updatedDocument = reducer(document, setPackageAuthor(input));
|
|
225
|
+
expect(isVetraPackageDocument(updatedDocument)).toBe(true);
|
|
226
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
227
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PACKAGE_AUTHOR");
|
|
228
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
229
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
230
|
+
});
|
|
231
|
+
it("should handle setPackageAuthorName operation", () => {
|
|
232
|
+
const document = utils.createDocument();
|
|
233
|
+
const input = generateMock(SetPackageAuthorNameInputSchema());
|
|
234
|
+
const updatedDocument = reducer(document, setPackageAuthorName(input));
|
|
235
|
+
expect(isVetraPackageDocument(updatedDocument)).toBe(true);
|
|
236
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
237
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PACKAGE_AUTHOR_NAME");
|
|
238
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
239
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
240
|
+
});
|
|
241
|
+
it("should handle setPackageAuthorWebsite operation", () => {
|
|
242
|
+
const document = utils.createDocument();
|
|
243
|
+
const input = generateMock(SetPackageAuthorWebsiteInputSchema());
|
|
244
|
+
const updatedDocument = reducer(document, setPackageAuthorWebsite(input));
|
|
245
|
+
expect(isVetraPackageDocument(updatedDocument)).toBe(true);
|
|
246
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
247
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PACKAGE_AUTHOR_WEBSITE");
|
|
248
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
249
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
250
|
+
});
|
|
251
|
+
it("should handle addPackageKeyword operation", () => {
|
|
252
|
+
const document = utils.createDocument();
|
|
253
|
+
const input = generateMock(AddPackageKeywordInputSchema());
|
|
254
|
+
const updatedDocument = reducer(document, addPackageKeyword(input));
|
|
255
|
+
expect(isVetraPackageDocument(updatedDocument)).toBe(true);
|
|
256
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
257
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("ADD_PACKAGE_KEYWORD");
|
|
258
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
259
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
260
|
+
});
|
|
261
|
+
it("should handle removePackageKeyword operation", () => {
|
|
262
|
+
const document = utils.createDocument();
|
|
263
|
+
const input = generateMock(RemovePackageKeywordInputSchema());
|
|
264
|
+
const updatedDocument = reducer(document, removePackageKeyword(input));
|
|
265
|
+
expect(isVetraPackageDocument(updatedDocument)).toBe(true);
|
|
266
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
267
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("REMOVE_PACKAGE_KEYWORD");
|
|
268
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
269
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
270
|
+
});
|
|
271
|
+
it("should handle setPackageGithubUrl operation", () => {
|
|
272
|
+
const document = utils.createDocument();
|
|
273
|
+
const input = generateMock(SetPackageGithubUrlInputSchema());
|
|
274
|
+
const updatedDocument = reducer(document, setPackageGithubUrl(input));
|
|
275
|
+
expect(isVetraPackageDocument(updatedDocument)).toBe(true);
|
|
276
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
277
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PACKAGE_GITHUB_URL");
|
|
278
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
279
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
280
|
+
});
|
|
281
|
+
it("should handle setPackageNpmUrl operation", () => {
|
|
282
|
+
const document = utils.createDocument();
|
|
283
|
+
const input = generateMock(SetPackageNpmUrlInputSchema());
|
|
284
|
+
const updatedDocument = reducer(document, setPackageNpmUrl(input));
|
|
285
|
+
expect(isVetraPackageDocument(updatedDocument)).toBe(true);
|
|
286
|
+
expect(updatedDocument.operations.global).toHaveLength(1);
|
|
287
|
+
expect(updatedDocument.operations.global[0].action.type).toBe("SET_PACKAGE_NPM_URL");
|
|
288
|
+
expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
|
|
289
|
+
expect(updatedDocument.operations.global[0].index).toEqual(0);
|
|
290
|
+
});
|
|
192
291
|
});
|