Added select tests
This commit is contained in:
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