@@ -44,36 +44,38 @@ describe("checking tutorial functions", () => {
4444 expect ( response . status ) . toBe ( 200 ) ;
4545 expect ( response . body . res ) . toMatch ( / a d d e d t u t o r i a l / ) ;
4646 } ) ;
47-
48- let tutorialId ;
49- beforeEach ( async ( ) => {
50- const id = agent . post ( "/tutorial/add" ) . send ( {
51- no : "123" ,
52- title : "abc" ,
53- hours : "3" ,
54- cognitiveLevel : [ "L1" , "L2" ] ,
47+
48+ describe ( "after creating a practical" , ( ) => {
49+ let tutorialId ;
50+ beforeEach ( async ( ) => {
51+ const id = await agent . post ( "/tutorial/add" ) . send ( {
52+ no : "456" ,
53+ title : "dfg" ,
54+ hours : "3" ,
55+ cognitiveLevel : [ "L1" , "L2" ] ,
56+ } ) ;
57+ tutorialId = JSON . parse ( id . res . text ) . id ;
5558 } ) ;
56- tutorialId = JSON . parse ( id . res . text ) . id ;
57- } ) ;
5859
59- afterEach ( async ( ) => {
60- await tutorialModel . remove ( { no : "123" } ) ;
61- } ) ;
60+ afterEach ( async ( ) => {
61+ await tutorialModel . remove ( ) ;
62+ } ) ;
6263
63- it ( "read tutorial" , async ( ) => {
64- const response = await agent
65- . get ( "/tutorial/list" )
66- . send ( { name : "xyz " } ) ;
67- expect ( response . status ) . toBe ( 200 ) ;
68- expect ( response . body . res ) . toBeDefined ( ) ;
69- } ) ;
64+ it ( "read tutorial" , async ( ) => {
65+ const response = await agent
66+ . get ( "/tutorial/list" )
67+ . send ( { name : "dfg " } ) ;
68+ expect ( response . status ) . toBe ( 200 ) ;
69+ expect ( response . body . res ) . toBeDefined ( ) ;
70+ } ) ;
7071
71- it ( "update tutorial" , async ( ) => {
72- const response = await agent
73- . post ( `/tutorial/update+${ tutorialId } ` )
74- . send ( { no : "123" } , { no : "123" } ) ;
75- expect ( response . headers [ "content-type" ] ) . toMatch ( / j s o n / ) ;
76- expect ( response . status ) . toBe ( 200 ) ;
77- expect ( response . body . res ) . toMatch ( / t u t o r i a l u p d a t e d / ) ;
72+ it ( "update tutorial" , async ( ) => {
73+ const response = await agent
74+ . post ( `/tutorial/update/${ tutorialId } ` )
75+ . send ( { no : "456" } ) ;
76+ expect ( response . headers [ "content-type" ] ) . toMatch ( / j s o n / ) ;
77+ expect ( response . status ) . toBe ( 200 ) ;
78+ expect ( response . body . res ) . toMatch ( / t u t o r i a l u p d a t e d / ) ;
79+ } ) ;
7880 } ) ;
7981} ) ;
0 commit comments