@@ -6,27 +6,27 @@ import { buildMappingFile } from '../src/Generator.js';
66describe ( 'buildMappingFile' , ( ) => {
77 it ( 'should build a valid mapping file' , ( ) => {
88 const expectedMapping = `import { Id } from '@graphprotocol/grc-20';
9- import type { Mapping } from '@graphprotocol/hypergraph ';
9+ import type { Mapping } from '@graphprotocol/typesync/Mapping ';
1010
1111export const mapping: Mapping = {
1212 Space: {
13- typeIds: [Id.Id(' 362c1dbd-dc64-44bb-a3c4-652f38a642d7' )],
13+ typeIds: [Id.Id(" 362c1dbd-dc64-44bb-a3c4-652f38a642d7" )],
1414 properties: {
15- name: Id.Id(' a126ca53-0c8e-48d5-b888-82c734c38935' ),
16- description: Id.Id(' 9b1f76ff-9711-404c-861e-59dc3fa7d037'),
15+ name: Id.Id(" a126ca53-0c8e-48d5-b888-82c734c38935" ),
16+ description: Id.Id(" 9b1f76ff-9711-404c-861e-59dc3fa7d037")
1717 },
1818 },
1919 Activity: {
20- typeIds: [Id.Id(' 8275c359-4662-40fb-9aec-27177b520cd2' )],
20+ typeIds: [Id.Id(" 8275c359-4662-40fb-9aec-27177b520cd2" )],
2121 properties: {
22- name: Id.Id(' a126ca53-0c8e-48d5-b888-82c734c38935' ),
23- description: Id.Id(' 9b1f76ff-9711-404c-861e-59dc3fa7d037'),
22+ name: Id.Id(" a126ca53-0c8e-48d5-b888-82c734c38935" ),
23+ description: Id.Id(" 9b1f76ff-9711-404c-861e-59dc3fa7d037")
2424 },
2525 relations: {
26- relatedSpaces: Id.Id(' 5b722cd3-61d6-494e-8887-1310566437ba'),
26+ relatedSpaces: Id.Id(" 5b722cd3-61d6-494e-8887-1310566437ba")
2727 },
2828 },
29- }; ` ;
29+ }` ;
3030
3131 const mapping = buildMappingFile ( {
3232 name : 'test' ,
@@ -67,137 +67,14 @@ export const mapping: Mapping = {
6767 {
6868 name : 'Related spaces' ,
6969 knowledgeGraphId : '5b722cd3-61d6-494e-8887-1310566437ba' ,
70- dataType : 'Relation(Related spaces )' ,
71- relationType : 'Related spaces ' ,
70+ dataType : 'Relation(Space )' ,
71+ relationType : 'Space ' ,
7272 } ,
7373 ] ,
7474 } ,
7575 ] ,
7676 } ) ;
77- expect ( mapping ) . toBe ( expectedMapping ) ;
78- } ) ;
79-
80- it ( 'should skip a type entry without a knowledgeGraphId' , ( ) => {
81- const expectedMapping = `import { Id } from '@graphprotocol/grc-20';
82- import type { Mapping } from '@graphprotocol/hypergraph';
8377
84- export const mapping: Mapping = {
85- Space: {
86- typeIds: [Id.Id('362c1dbd-dc64-44bb-a3c4-652f38a642d7')],
87- properties: {
88- name: Id.Id('a126ca53-0c8e-48d5-b888-82c734c38935'),
89- description: Id.Id('9b1f76ff-9711-404c-861e-59dc3fa7d037'),
90- },
91- },
92- };` ;
93-
94- const mapping = buildMappingFile ( {
95- name : 'test' ,
96- description : 'test' ,
97- directory : 'test' ,
98- template : 'vite_react' ,
99- types : [
100- {
101- name : 'Space' ,
102- knowledgeGraphId : '362c1dbd-dc64-44bb-a3c4-652f38a642d7' ,
103- properties : [
104- {
105- name : 'Name' ,
106- knowledgeGraphId : 'a126ca53-0c8e-48d5-b888-82c734c38935' ,
107- dataType : 'Text' ,
108- } ,
109- {
110- name : 'Description' ,
111- knowledgeGraphId : '9b1f76ff-9711-404c-861e-59dc3fa7d037' ,
112- dataType : 'Text' ,
113- } ,
114- ] ,
115- } ,
116- {
117- name : 'new type' ,
118- knowledgeGraphId : null ,
119- properties : [
120- {
121- name : 'new prop' ,
122- knowledgeGraphId : null ,
123- dataType : 'Text' ,
124- } ,
125- ] ,
126- } ,
127- ] ,
128- } ) ;
129- expect ( mapping ) . toBe ( expectedMapping ) ;
130- } ) ;
131-
132- it ( 'should skip a property entry without a knowledgeGraphId' , ( ) => {
133- const expectedMapping = `import { Id } from '@graphprotocol/grc-20';
134- import type { Mapping } from '@graphprotocol/hypergraph';
135-
136- export const mapping: Mapping = {
137- Space: {
138- typeIds: [Id.Id('362c1dbd-dc64-44bb-a3c4-652f38a642d7')],
139- properties: {
140- name: Id.Id('a126ca53-0c8e-48d5-b888-82c734c38935'),
141- description: Id.Id('9b1f76ff-9711-404c-861e-59dc3fa7d037'),
142- },
143- },
144- Activity: {
145- typeIds: [Id.Id('8275c359-4662-40fb-9aec-27177b520cd2')],
146- properties: {
147- name: Id.Id('a126ca53-0c8e-48d5-b888-82c734c38935'),
148- },
149- relations: {
150- relatedSpaces: Id.Id('5b722cd3-61d6-494e-8887-1310566437ba'),
151- },
152- },
153- };` ;
154-
155- const mapping = buildMappingFile ( {
156- name : 'test' ,
157- description : 'test' ,
158- directory : 'test' ,
159- template : 'vite_react' ,
160- types : [
161- {
162- name : 'Space' ,
163- knowledgeGraphId : '362c1dbd-dc64-44bb-a3c4-652f38a642d7' ,
164- properties : [
165- {
166- name : 'Name' ,
167- knowledgeGraphId : 'a126ca53-0c8e-48d5-b888-82c734c38935' ,
168- dataType : 'Text' ,
169- } ,
170- {
171- name : 'Description' ,
172- knowledgeGraphId : '9b1f76ff-9711-404c-861e-59dc3fa7d037' ,
173- dataType : 'Text' ,
174- } ,
175- ] ,
176- } ,
177- {
178- name : 'Activity' ,
179- knowledgeGraphId : '8275c359-4662-40fb-9aec-27177b520cd2' ,
180- properties : [
181- {
182- name : 'Name' ,
183- knowledgeGraphId : 'a126ca53-0c8e-48d5-b888-82c734c38935' ,
184- dataType : 'Text' ,
185- } ,
186- {
187- name : 'Description' ,
188- knowledgeGraphId : null ,
189- dataType : 'Text' ,
190- } ,
191- {
192- name : 'Related spaces' ,
193- knowledgeGraphId : '5b722cd3-61d6-494e-8887-1310566437ba' ,
194- dataType : 'Relation(Related spaces)' ,
195- relationType : 'Related spaces' ,
196- } ,
197- ] ,
198- } ,
199- ] ,
200- } ) ;
20178 expect ( mapping ) . toBe ( expectedMapping ) ;
20279 } ) ;
20380} ) ;
0 commit comments