Skip to content

Commit f75247c

Browse files
committed
feat(typesync pkg): add partially existing test-case
1 parent 55f79ae commit f75247c

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

packages/typesync/test/Mapping.test.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Id } from '@graphprotocol/grc-20';
12
import { describe, expect, it } from 'vitest';
23

34
import { type Mapping, generateMapping, mapSchemaDataTypeToGRC20PropDataType } from '../src/Mapping.js';
@@ -76,6 +77,68 @@ describe('Mapping', () => {
7677
},
7778
};
7879

80+
expect(actual).toEqual(expected);
81+
});
82+
it('should use the existing KG ids if provided', async () => {
83+
const actual = await generateMapping({
84+
types: [
85+
{
86+
name: 'Account',
87+
knowledgeGraphId: 'a5fd07b1-120f-46c6-b46f-387ef98396a6',
88+
properties: [
89+
{
90+
name: 'username',
91+
dataType: 'Text',
92+
knowledgeGraphId: '994edcff-6996-4a77-9797-a13e5e3efad8',
93+
},
94+
{
95+
name: 'createdAt',
96+
dataType: 'Date',
97+
knowledgeGraphId: '64bfba51-a69b-4746-be4b-213214a879fe',
98+
},
99+
],
100+
},
101+
{
102+
name: 'Event',
103+
knowledgeGraphId: null,
104+
properties: [
105+
{
106+
name: 'name',
107+
dataType: 'Text',
108+
knowledgeGraphId: '3808e060-fb4a-4d08-8069-35b8c8a1902b',
109+
},
110+
{
111+
name: 'description',
112+
dataType: 'Text',
113+
knowledgeGraphId: null,
114+
},
115+
{
116+
name: 'speaker',
117+
dataType: 'Relation(Account)',
118+
knowledgeGraphId: null,
119+
},
120+
],
121+
},
122+
],
123+
});
124+
const expected: Mapping = {
125+
Account: {
126+
typeIds: [Id.Id('a5fd07b1-120f-46c6-b46f-387ef98396a6')],
127+
properties: {
128+
username: Id.Id('994edcff-6996-4a77-9797-a13e5e3efad8'),
129+
createdAt: Id.Id('64bfba51-a69b-4746-be4b-213214a879fe'),
130+
},
131+
},
132+
Event: {
133+
typeIds: [expect.any(String)],
134+
properties: {
135+
name: Id.Id('3808e060-fb4a-4d08-8069-35b8c8a1902b'),
136+
description: expect.any(String),
137+
speaker: expect.any(String),
138+
},
139+
},
140+
};
141+
79142
expect(actual).toEqual(expected);
80143
});
81144
});

0 commit comments

Comments
 (0)