@@ -83,4 +83,103 @@ describe("EActivitiesAPI", () => {
8383 response ,
8484 ) ;
8585 } ) ;
86+
87+ // =================
88+ // Shop admin tests
89+ // =================
90+
91+ it ( "should get all products" , async ( ) => {
92+ /// @ts -expect-error: Mocking the response
93+ const response : Product [ ] = [
94+ {
95+ ID : 1234 ,
96+ Name : "Test Product" ,
97+ Description : "Test Description" ,
98+ Type : "Test Type" ,
99+ SellingDateStart : "2022-01-01" ,
100+ SellingDateEnd : "2022-12-31" ,
101+ URL : "http://example.com" ,
102+ Active : true ,
103+ ProductLines : [ ] ,
104+ } ,
105+ ] ;
106+ await testRequest ( "getProducts" , `/${ centreNumber } /products` , "GET" , response ) ;
107+ } ) ;
108+
109+ it ( "should get products by academic year" , async ( ) => {
110+ /// @ts -expect-error: Mocking the response
111+ const response : Product [ ] = [
112+ {
113+ ID : 1234 ,
114+ Name : "Test Product" ,
115+ Description : "Test Description" ,
116+ Type : "Test Type" ,
117+ SellingDateStart : "2022-01-01" ,
118+ SellingDateEnd : "2022-12-31" ,
119+ URL : "http://example.com" ,
120+ Active : true ,
121+ ProductLines : [ ] ,
122+ } ,
123+ ] ;
124+ await testRequest (
125+ "getProductsByAcademicYear" ,
126+ `/${ centreNumber } /reports/products?year=${ academicYear } ` ,
127+ "GET" ,
128+ response ,
129+ ) ;
130+ } ) ;
131+
132+ it ( "should get product by ID" , async ( ) => {
133+ /// @ts -expect-error: Mocking the response
134+ const response : Product = {
135+ ID : 1234 ,
136+ Name : "Test Product" ,
137+ Description : "Test Description" ,
138+ Type : "Test Type" ,
139+ SellingDateStart : "2022-01-01" ,
140+ SellingDateEnd : "2022-12-31" ,
141+ URL : "http://example.com" ,
142+ Active : true ,
143+ ProductLines : [ ] ,
144+ } ;
145+ await testRequest (
146+ "getProductById" ,
147+ `/${ centreNumber } /products/1234` ,
148+ "GET" ,
149+ response ,
150+ "123" ,
151+ 1234 ,
152+ ) ;
153+ } ) ;
154+
155+ it ( "should get product sales" , async ( ) => {
156+ /// @ts -expect-error: Mocking the response
157+ const response : Sale [ ] = [
158+ {
159+ OrderNumber : "1000" ,
160+ SaleDateTime : "2022-01-01 12:00:00" ,
161+ ProductID : 1234 ,
162+ ProductLineID : 4567 ,
163+ Price : 30 ,
164+ Quantity : 1 ,
165+ QuantityCollected : 0 ,
166+ Customer : {
167+ FirstName : "John" ,
168+ Surname : "Doe" ,
169+ CID : "00000000" ,
170+ Email : "john.doe@example.com" ,
171+ Login : "jdoe" ,
172+ } ,
173+ VAT : { Code : "S1" , Name : "S1 – Sales Standard Rated" , Rate : 20 } ,
174+ } ,
175+ ] ;
176+ await testRequest (
177+ "getProductSales" ,
178+ `/${ centreNumber } /products/1234/sales` ,
179+ "GET" ,
180+ response ,
181+ "123" ,
182+ 1234 ,
183+ ) ;
184+ } ) ;
86185} ) ;
0 commit comments