File tree Expand file tree Collapse file tree 3 files changed +126
-0
lines changed
packages/types/src/schemas Expand file tree Collapse file tree 3 files changed +126
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { describe , it , expect } from 'vitest' ;
2
+ import { chapterSchema } from './chapter.js' ;
3
+
4
+ describe ( 'chapterSchema' , ( ) => {
5
+ it ( 'should validate a valid chapter object' , ( ) => {
6
+ expect ( ( ) =>
7
+ chapterSchema . parse ( {
8
+ title : 'Chapter 1' ,
9
+ type : 'chapter' ,
10
+ slug : 'chapter-one' ,
11
+ } ) ,
12
+ ) . not . toThrow ( ) ;
13
+ } ) ;
14
+
15
+ it ( 'should validate a chapter object without optional properties' , ( ) => {
16
+ expect ( ( ) =>
17
+ chapterSchema . parse ( {
18
+ title : 'Chapter 1' ,
19
+ type : 'chapter' ,
20
+ } ) ,
21
+ ) . not . toThrow ( ) ;
22
+ } ) ;
23
+
24
+ it ( 'should throw an error for a chapter object with invalid type' , ( ) => {
25
+ expect ( ( ) =>
26
+ chapterSchema . parse ( {
27
+ title : 'Chapter 1' ,
28
+ type : 'invalid' ,
29
+ } ) ,
30
+ ) . toThrow ( ) ;
31
+ } ) ;
32
+
33
+ it ( 'should throw an error for a chapter object with missing type property' , ( ) => {
34
+ expect ( ( ) =>
35
+ chapterSchema . parse ( {
36
+ title : 'Chapter 1' ,
37
+ } ) ,
38
+ ) . toThrow ( ) ;
39
+ } ) ;
40
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { describe , it , expect } from 'vitest' ;
2
+ import { partSchema } from './part.js' ;
3
+
4
+ describe ( 'partSchema' , ( ) => {
5
+ it ( 'should validate a valid part object' , ( ) => {
6
+ expect ( ( ) =>
7
+ partSchema . parse ( {
8
+ title : 'Part 1' ,
9
+ type : 'part' ,
10
+ slug : 'part-one' ,
11
+ } ) ,
12
+ ) . not . toThrow ( ) ;
13
+ } ) ;
14
+
15
+ it ( 'should validate a part object without optional properties' , ( ) => {
16
+ expect ( ( ) =>
17
+ partSchema . parse ( {
18
+ title : 'Part 1' ,
19
+ type : 'part' ,
20
+ } ) ,
21
+ ) . not . toThrow ( ) ;
22
+ } ) ;
23
+
24
+ it ( 'should throw an error for a part object with invalid type' , ( ) => {
25
+ expect ( ( ) =>
26
+ partSchema . parse ( {
27
+ title : 'Part 1' ,
28
+ type : 'invalid' ,
29
+ } ) ,
30
+ ) . toThrow ( ) ;
31
+ } ) ;
32
+
33
+ it ( 'should throw an error for a part object with missing type property' , ( ) => {
34
+ expect ( ( ) =>
35
+ partSchema . parse ( {
36
+ title : 'Part 1' ,
37
+ } ) ,
38
+ ) . toThrow ( ) ;
39
+ } ) ;
40
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { describe , it , expect } from 'vitest' ;
2
+ import { tutorialSchema } from '../schemas/tutorial.js' ;
3
+
4
+ describe ( 'tutorialSchema' , ( ) => {
5
+ it ( 'should validate a valid tutorial object' , ( ) => {
6
+ expect ( ( ) =>
7
+ tutorialSchema . parse ( {
8
+ type : 'tutorial' ,
9
+ logoLink : 'https://example.com/logo.png' ,
10
+ } ) ,
11
+ ) . not . toThrow ( ) ;
12
+ } ) ;
13
+
14
+ it ( 'should validate a tutorial object without optional properties' , ( ) => {
15
+ expect ( ( ) =>
16
+ tutorialSchema . parse ( {
17
+ type : 'tutorial' ,
18
+ } ) ,
19
+ ) . not . toThrow ( ) ;
20
+ } ) ;
21
+
22
+ it ( 'should throw an error for a tutorial object with invalid type' , ( ) => {
23
+ expect ( ( ) =>
24
+ tutorialSchema . parse ( {
25
+ type : 'invalid' ,
26
+ } ) ,
27
+ ) . toThrow ( ) ;
28
+ } ) ;
29
+
30
+ it ( 'should throw an error for a tutorial object with invalid logoLink' , ( ) => {
31
+ expect ( ( ) =>
32
+ tutorialSchema . parse ( {
33
+ type : 'tutorial' ,
34
+ logoLink : 123 ,
35
+ } ) ,
36
+ ) . toThrow ( ) ;
37
+ } ) ;
38
+
39
+ it ( 'should throw an error for a tutorial object with missing type property' , ( ) => {
40
+ expect ( ( ) =>
41
+ tutorialSchema . parse ( {
42
+ logoLink : 'https://example.com/logo.png' ,
43
+ } ) ,
44
+ ) . toThrow ( ) ;
45
+ } ) ;
46
+ } ) ;
You can’t perform that action at this time.
0 commit comments