1- import { describe , expect , test } from 'vitest' ;
1+ import { beforeEach , describe , expect , test } from 'vitest' ;
22import Schema from './schema.js' ;
33
44describe ( 'Schema' , ( ) => {
@@ -16,34 +16,29 @@ describe('Schema', () => {
1616 }
1717 ` ;
1818
19- test ( 'getEntityNames returns all entity types' , async ( ) => {
20- const schema = await Schema . loadFromString ( schemaDocument ) ;
19+ let schema : Schema ;
20+
21+ beforeEach ( async ( ) => {
22+ schema = await Schema . loadFromString ( schemaDocument ) ;
23+ } ) ;
24+
25+ test ( 'getEntityNames returns all entity types' , ( ) => {
2126 const entityNames = schema . getEntityNames ( ) ;
2227 expect ( entityNames ) . toEqual ( [ 'Entity1' , 'Entity2' , 'Entity3' ] ) ;
2328 } ) ;
2429
25- test ( 'getImmutableEntityNames returns only immutable entity types' , async ( ) => {
26- const schema = await Schema . loadFromString ( schemaDocument ) ;
30+ test ( 'getImmutableEntityNames returns only immutable entity types' , ( ) => {
2731 const immutableEntityNames = schema . getImmutableEntityNames ( ) ;
2832 expect ( immutableEntityNames ) . toEqual ( [ 'Entity2' ] ) ;
2933 } ) ;
3034
31- test ( 'getImmutableEntityNames handles entities without immutable flag' , async ( ) => {
32- const schema = await Schema . loadFromString ( schemaDocument ) ;
35+ test ( 'getImmutableEntityNames handles entities without immutable flag' , ( ) => {
3336 const immutableEntityNames = schema . getImmutableEntityNames ( ) ;
3437 expect ( immutableEntityNames ) . not . toContain ( 'Entity1' ) ;
3538 } ) ;
3639
37- test ( 'getImmutableEntityNames handles explicitly non-immutable entities' , async ( ) => {
38- const schema = await Schema . loadFromString ( schemaDocument ) ;
39- const immutableEntityNames = schema . getImmutableEntityNames ( ) ;
40- expect ( immutableEntityNames ) . not . toContain ( 'Entity3' ) ;
41- } ) ;
42-
43- test ( 'getImmutableEntityNames ignores non-entity types' , async ( ) => {
44- const schema = await Schema . loadFromString ( schemaDocument ) ;
40+ test ( 'getImmutableEntityNames handles explicitly non-immutable entities' , ( ) => {
4541 const immutableEntityNames = schema . getImmutableEntityNames ( ) ;
46- expect ( immutableEntityNames ) . not . toContain ( 'Entity1' ) ;
4742 expect ( immutableEntityNames ) . not . toContain ( 'Entity3' ) ;
4843 } ) ;
4944} ) ;
0 commit comments