@@ -5,7 +5,17 @@ import { sep } from 'path';
5
5
const version = __dirname . split ( sep ) . reverse ( ) [ 0 ] ;
6
6
const endpoint = `${ version } /hello` ;
7
7
8
+ /**
9
+ * Test suite for the 'hello' endpoint
10
+ * @param {string } endpoint - The base URL of the hello endpoint
11
+ * @returns {void } No return value
12
+ */
8
13
describe ( 'hello:' , ( ) => {
14
+ /**
15
+ * Tests the GET request to the specified endpoint with a missing "name" query parameter
16
+ * @param {string } endpoint - The API endpoint being tested
17
+ * @returns {void } This test function doesn't return a value
18
+ */
9
19
it ( `GET ${ endpoint } - missing "name" query parameter - returns 400` , async ( ) => {
10
20
const res = await request ( {
11
21
method : 'GET' ,
@@ -15,6 +25,11 @@ describe('hello:', () => {
15
25
expect ( res . result . error ) . to . equal ( '"name" is required' ) ;
16
26
} ) ;
17
27
28
+ /**
29
+ * Tests the GET request to the specified endpoint with a "name" query parameter
30
+ * @param {string } endpoint - The API endpoint to be tested
31
+ * @returns {void } This test function doesn't return a value
32
+ */
18
33
it ( `GET ${ endpoint } - with "name" query parmeter - returns 200` , async ( ) => {
19
34
const res = await request ( {
20
35
method : 'GET' ,
@@ -24,6 +39,11 @@ describe('hello:', () => {
24
39
expect ( res . result ) . to . toMatchObject ( { hello : 'world' } ) ;
25
40
} ) ;
26
41
42
+ /**
43
+ * Tests the GET request to {endpoint}/{name} for a 200 status code and correct response body
44
+ * @param {string } endpoint - The base endpoint URL for the API
45
+ * @returns {void } This test function does not return a value
46
+ */
27
47
it ( `GET ${ endpoint } /{name} - returns 200` , async ( ) => {
28
48
const res = await request ( {
29
49
method : 'GET' ,
@@ -33,6 +53,11 @@ describe('hello:', () => {
33
53
expect ( res . result ) . to . toMatchObject ( { hello : 'world' } ) ;
34
54
} ) ;
35
55
56
+ /**
57
+ * Tests the POST request to the specified endpoint
58
+ * @param {string } endpoint - The API endpoint to be tested
59
+ * @returns {void } This test function doesn't return a value
60
+ */
36
61
it ( `POST ${ endpoint } - returns 201` , async ( ) => {
37
62
const res = await request ( {
38
63
method : 'POST' ,
@@ -46,6 +71,11 @@ describe('hello:', () => {
46
71
expect ( res . result ) . to . toMatchObject ( { hello : 'world' } ) ;
47
72
} ) ;
48
73
74
+ /**
75
+ * Tests the PUT request to the specified endpoint with a name parameter
76
+ * @param {string } endpoint - The base endpoint for the API
77
+ * @returns {void } No return value
78
+ */
49
79
it ( `PUT ${ endpoint } /{name} - returns 200` , async ( ) => {
50
80
const res = await request ( {
51
81
method : 'PUT' ,
@@ -58,6 +88,11 @@ describe('hello:', () => {
58
88
expect ( res . result ) . to . toMatchObject ( { hello : 'world' , comment : 'hello' } ) ;
59
89
} ) ;
60
90
91
+ /**
92
+ * Tests the DELETE endpoint for a specific name
93
+ * @param {string } endpoint - The base endpoint URL
94
+ * @returns {void } No return value
95
+ */
61
96
it ( `DELETE ${ endpoint } /{name} - returns 200` , async ( ) => {
62
97
const res = await request ( {
63
98
method : 'DELETE' ,
0 commit comments