-
Notifications
You must be signed in to change notification settings - Fork 222
/
Copy pathschema.test.ts
44 lines (35 loc) · 1.24 KB
/
schema.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { beforeEach, describe, expect, test } from 'vitest';
import Schema from './schema.js';
describe('Schema', () => {
const schemaDocument = `
type Entity1 @entity {
id: ID!
}
type Entity2 @entity(immutable: true) {
id: ID!
}
type Entity3 @entity(immutable: false) {
id: ID!
}
`;
let schema: Schema;
beforeEach(async () => {
schema = await Schema.loadFromString(schemaDocument);
});
test('getEntityNames returns all entity types', () => {
const entityNames = schema.getEntityNames();
expect(entityNames).toEqual(['Entity1', 'Entity2', 'Entity3']);
});
test('getImmutableEntityNames returns only immutable entity types', () => {
const immutableEntityNames = schema.getImmutableEntityNames();
expect(immutableEntityNames).toEqual(['Entity2']);
});
test('getImmutableEntityNames handles entities without immutable flag', () => {
const immutableEntityNames = schema.getImmutableEntityNames();
expect(immutableEntityNames).not.toContain('Entity1');
});
test('getImmutableEntityNames handles explicitly non-immutable entities', () => {
const immutableEntityNames = schema.getImmutableEntityNames();
expect(immutableEntityNames).not.toContain('Entity3');
});
});