1+ import { SchemaDto } from "../src/api" ;
2+ import { getClient , guid } from "./_utils" ;
3+
4+ const { client } = getClient ( ) ;
5+
6+ let createdSchema : SchemaDto ;
7+
8+ beforeAll ( async ( ) => {
9+ createdSchema = await client . schemas . postSchema ( {
10+ name : `schema-${ guid ( ) } ` ,
11+ fields : [ {
12+ name : 'field1' ,
13+ properties : {
14+ fieldType : 'String' ,
15+ } ,
16+ } ] ,
17+ isPublished : true ,
18+ } ) ;
19+ } ) ;
20+
21+ describe ( "Contents" , ( ) => {
22+ it ( "should create and fetch content" , async ( ) => {
23+ const value = guid ( ) ;
24+
25+ const createdContent = await client . contents . postContent ( createdSchema . name , {
26+ body : {
27+ field1 : {
28+ iv : value
29+ }
30+ } ,
31+ publish : true
32+ } ) ;
33+
34+ const content = await client . contents . getContent ( createdSchema . name , createdContent . id ) ;
35+ expect ( content . data ) . toEqual ( { field1 : { iv : value } } ) ;
36+ expect ( content . lastModified ) . toBeDefined ( ) ;
37+ expect ( content . lastModifiedBy ) . toBeDefined ( ) ;
38+ expect ( content . status ) . toEqual ( 'Published' ) ;
39+ } ) ;
40+
41+ it ( "should create and fetch unpublished content" , async ( ) => {
42+ const value = guid ( ) ;
43+
44+ const createdContent = await client . contents . postContent ( createdSchema . name , {
45+ body : {
46+ field1 : {
47+ iv : value
48+ }
49+ }
50+ } ) ;
51+
52+ const content = await client . contents . getContent ( createdSchema . name , createdContent . id , { unpublished : true } ) ;
53+ expect ( content . data ) . toEqual ( { field1 : { iv : value } } ) ;
54+ expect ( content . lastModified ) . toBeDefined ( ) ;
55+ expect ( content . lastModifiedBy ) . toBeDefined ( ) ;
56+ expect ( content . status ) . toEqual ( 'Draft' ) ;
57+ } ) ;
58+ } )
0 commit comments