@@ -3,6 +3,7 @@ import supertest from "supertest";
33import app from "../src/app" ;
44import {
55 MONGO_OBJ_ID_MALFORMED_MESSAGE ,
6+ ORDER_INCORRECT_FORMAT_MESSAGE ,
67 PAGE_LIMIT_INCORRECT_FORMAT_MESSAGE ,
78 PAGE_LIMIT_USERID_ORDER_REQUIRED_MESSAGE ,
89 QN_HIST_NOT_FOUND_MESSAGE ,
@@ -24,6 +25,7 @@ describe("Qn History Routes", () => {
2425 const submissionStatus = "Attempted" ;
2526 const dateAttempted = new Date ( ) ;
2627 const timeTaken = 0 ;
28+ const code = "hi" ;
2729 const language = "Python" ;
2830 const newQnHistory = {
2931 userIds,
@@ -32,6 +34,7 @@ describe("Qn History Routes", () => {
3234 submissionStatus,
3335 dateAttempted,
3436 timeTaken,
37+ code,
3538 language,
3639 } ;
3740
@@ -46,6 +49,7 @@ describe("Qn History Routes", () => {
4649 dateAttempted . toISOString ( )
4750 ) ;
4851 expect ( res . body . qnHistory . timeTaken ) . toBe ( timeTaken ) ;
52+ expect ( res . body . qnHistory . code ) . toBe ( code ) ;
4953 expect ( res . body . qnHistory . language ) . toBe ( language ) ;
5054 } ) ;
5155 } ) ;
@@ -84,6 +88,14 @@ describe("Qn History Routes", () => {
8488 expect ( res . body . message ) . toBe ( PAGE_LIMIT_USERID_ORDER_REQUIRED_MESSAGE ) ;
8589 } ) ;
8690
91+ it ( "Does not read without order" , async ( ) => {
92+ const res = await request . get (
93+ `${ BASE_URL } ?page=1&qnHistLimit=10&userId=66f77e9f27ab3f794bdae664`
94+ ) ;
95+ expect ( res . status ) . toBe ( 400 ) ;
96+ expect ( res . body . message ) . toBe ( PAGE_LIMIT_USERID_ORDER_REQUIRED_MESSAGE ) ;
97+ } ) ;
98+
8799 it ( "Does not read with negative page" , async ( ) => {
88100 const res = await request . get (
89101 `${ BASE_URL } ?page=-1&qnHistLimit=10&userId=66f77e9f27ab3f794bdae664&order=1`
@@ -107,6 +119,14 @@ describe("Qn History Routes", () => {
107119 expect ( res . status ) . toBe ( 400 ) ;
108120 expect ( res . body . message ) . toBe ( MONGO_OBJ_ID_MALFORMED_MESSAGE ) ;
109121 } ) ;
122+
123+ it ( "Does not read with invalid order" , async ( ) => {
124+ const res = await request . get (
125+ `${ BASE_URL } ?page=1&qnHistLimit=10&userId=66f77e9f27ab3f794bdae664&order=2`
126+ ) ;
127+ expect ( res . status ) . toBe ( 400 ) ;
128+ expect ( res . body . message ) . toBe ( ORDER_INCORRECT_FORMAT_MESSAGE ) ;
129+ } ) ;
110130 } ) ;
111131
112132 describe ( "GET /:id" , ( ) => {
0 commit comments