Compare commits
10 Commits
5caa06db66
...
97e416055c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97e416055c | ||
| 1f5fb1663e | |||
|
|
1ed2f3c836 | ||
| f148350b78 | |||
| fafb2ecd1b | |||
|
|
61c2dfb392 | ||
| 9b0533631b | |||
| 8e9fecf99a | |||
| 161be6f910 | |||
| dda925b8d6 |
20
Count.http
20
Count.http
@@ -21,4 +21,22 @@ GET /products
|
|||||||
test('OK content-range', () => {
|
test('OK content-range', () => {
|
||||||
expect(response.headers['content-range']).to.equal(`0-${itemsCount - 1}/*`);
|
expect(response.headers['content-range']).to.equal(`0-${itemsCount - 1}/*`);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
GET /products?offset=3&limit=8&unit_price=lt.14
|
||||||
|
Prefer: count=exact
|
||||||
|
?? status == 206
|
||||||
|
?? header content-range == 3-10/21
|
||||||
|
|
||||||
|
GET /products?offset=3&limit=25&unit_price=lt.14
|
||||||
|
Prefer: count=exact
|
||||||
|
?? status == 206
|
||||||
|
?? header content-range == 3-20/21
|
||||||
|
|
||||||
|
GET /products?offset=98&unit_price=lt.14
|
||||||
|
Prefer: count=exact
|
||||||
|
?? header content-range == */21
|
||||||
|
|
||||||
|
GET /products?limit=0&unit_price=lt.14
|
||||||
|
Prefer: count=exact
|
||||||
|
?? header content-range == */21
|
||||||
|
|||||||
14
Not.http
Normal file
14
Not.http
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
GET /Products?discontinued=not.is.false
|
||||||
|
|
||||||
|
?? status == 200
|
||||||
|
?? body length == 10
|
||||||
|
?? js response.parsedBody[0].product_name == Chai
|
||||||
|
?? js response.parsedBody[9].product_name == Perth Pasties
|
||||||
|
|
||||||
|
###
|
||||||
|
GET /Products?and=(id.lt.50,discontinued.not.is.false)
|
||||||
|
|
||||||
|
?? status == 200
|
||||||
|
?? body length == 9
|
||||||
|
?? js response.parsedBody[0].product_name == Chai
|
||||||
|
?? js response.parsedBody[8].product_name == Singaporean Hokkien Fried Mee
|
||||||
@@ -29,4 +29,13 @@ GET /products?order=product_name.desc
|
|||||||
?? js response.parsedBody[0].id == 47
|
?? js response.parsedBody[0].id == 47
|
||||||
?? js response.parsedBody[76].id == 17
|
?? js response.parsedBody[76].id == 17
|
||||||
?? js response.parsedBody[0].product_name startsWith Z
|
?? js response.parsedBody[0].product_name startsWith Z
|
||||||
?? js response.parsedBody[76].product_name startsWith A
|
?? js response.parsedBody[76].product_name startsWith A
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET /products?order=id.desc&unit_price=lt.10
|
||||||
|
?? status == 200
|
||||||
|
?? js response.parsedBody[0].id == 75
|
||||||
|
?? js response.parsedBody[10].id == 13
|
||||||
|
?? js response.parsedBody[0].product_name startsWith R
|
||||||
|
?? js response.parsedBody[10].product_name startsWith K
|
||||||
|
|||||||
56
Rest.http
56
Rest.http
@@ -12,7 +12,45 @@ GET /products
|
|||||||
?? body length == 77
|
?? body length == 77
|
||||||
|
|
||||||
###
|
###
|
||||||
|
GET /products?discontinued=neq.0
|
||||||
|
?? status == 200
|
||||||
|
?? body length == 10
|
||||||
|
|
||||||
|
###
|
||||||
|
GET /products?unit_price=is.null
|
||||||
|
?? status == 200
|
||||||
|
?? body length == 0
|
||||||
|
|
||||||
|
###
|
||||||
|
GET /products?product_name=in.(Chai,Chang,Aniseed Syrup)
|
||||||
|
?? status == 200
|
||||||
|
?? body length == 3
|
||||||
|
{{
|
||||||
|
const {expect} = require('chai');
|
||||||
|
let responseItems = JSON.parse(response.body);
|
||||||
|
test("OK in", () =>
|
||||||
|
{
|
||||||
|
expect(responseItems[0].id).to.equal(1);
|
||||||
|
expect(responseItems[1].id).to.equal(2);
|
||||||
|
expect(responseItems[2].id).to.equal(3);
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET /products?id=in.(1,2,79)
|
||||||
|
?? status == 200
|
||||||
|
?? body length == 2
|
||||||
|
{{
|
||||||
|
const {expect} = require('chai');
|
||||||
|
let responseItems = JSON.parse(response.body);
|
||||||
|
test("OK in", () =>
|
||||||
|
{
|
||||||
|
expect(responseItems[0].id).to.equal(1);
|
||||||
|
expect(responseItems[1].id).to.equal(2);
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
|
||||||
|
###
|
||||||
POST /products
|
POST /products
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
@@ -30,6 +68,24 @@ Content-Type: application/json
|
|||||||
}
|
}
|
||||||
?? status == 201
|
?? status == 201
|
||||||
|
|
||||||
|
###
|
||||||
|
POST /products
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"product_name": "Saffaron"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"product_name": "Chai"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"product_name": "sar"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
?? status == 201
|
||||||
|
|
||||||
###
|
###
|
||||||
{{
|
{{
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|||||||
88
Select.http
Normal file
88
Select.http
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
GET /products?select=id,unit_price,discontinued,supplier_id
|
||||||
|
?? status == 200
|
||||||
|
?? body length == 77
|
||||||
|
{{
|
||||||
|
const { expect } = require('chai');
|
||||||
|
let actual = JSON.parse(response.body)[0];
|
||||||
|
let expected = {
|
||||||
|
id: 1,
|
||||||
|
unit_price: 18,
|
||||||
|
discontinued: 1,
|
||||||
|
supplier_id: 8
|
||||||
|
}
|
||||||
|
test('OK Select', () => {
|
||||||
|
expect(JSON.stringify(expected)).to.equal(JSON.stringify(actual));
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
###
|
||||||
|
GET /products?select=id,unit_price,categories(category_name)
|
||||||
|
?? status == 200
|
||||||
|
?? body length == 77
|
||||||
|
{{
|
||||||
|
const { expect } = require('chai');
|
||||||
|
let actual = JSON.parse(response.body)[0];
|
||||||
|
let expected = {
|
||||||
|
id: 1,
|
||||||
|
unit_price: 18,
|
||||||
|
categories: {
|
||||||
|
category_name: "Beverages"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
test('OK Select', () => {
|
||||||
|
expect(JSON.stringify(expected)).to.equal(JSON.stringify(actual));
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
###
|
||||||
|
GET /categories?select=id,category_name,products(product_name)
|
||||||
|
?? status == 200
|
||||||
|
?? body length == 8
|
||||||
|
{{
|
||||||
|
const { expect } = require('chai');
|
||||||
|
let actual = JSON.parse(response.body)[0];
|
||||||
|
let expected = {
|
||||||
|
id: 1,
|
||||||
|
category_name: "Beverages",
|
||||||
|
products: [
|
||||||
|
{
|
||||||
|
product_name: "Chai"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Chang"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Guaraná Fantástica"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Sasquatch Ale"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Steeleye Stout"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Côte de Blaye"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Chartreuse verte"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Ipoh Coffee"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Laughing Lumberjack Lager"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Outback Lager"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Rhönbräu Klosterbier"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
product_name: "Lakkalikööri"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
test('OK Select', () => {
|
||||||
|
expect(JSON.stringify(expected)).to.equal(JSON.stringify(actual));
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
|
||||||
Reference in New Issue
Block a user