Init
This commit is contained in:
128
Rest.http
Normal file
128
Rest.http
Normal file
@@ -0,0 +1,128 @@
|
||||
{{
|
||||
const axios = require('axios');
|
||||
|
||||
const wait = axios.get(`${baseUrl}/products`).then(res => {
|
||||
let length = res.data.length;
|
||||
let exists = res.data.find(item => item.id === 78);
|
||||
if(length===78 && exists){
|
||||
return axios.delete(`${baseUrl}/products?id=eq.78`)
|
||||
.then(res => {
|
||||
return null;
|
||||
})
|
||||
}
|
||||
return null;
|
||||
})
|
||||
exports.wait = wait;
|
||||
}}
|
||||
###
|
||||
|
||||
GET {{baseUrl}}/products/1
|
||||
?? status == 200
|
||||
?? body product_name == Chai
|
||||
?? body id == 1
|
||||
|
||||
###
|
||||
|
||||
GET {{baseUrl}}/products
|
||||
?? status == 200
|
||||
?? body length == 77
|
||||
|
||||
###
|
||||
|
||||
POST {{baseUrl}}/products
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": 78,
|
||||
"product_name": "Saffaron",
|
||||
"discontinued": 0,
|
||||
"supplier_id": 12,
|
||||
"category_id": 2,
|
||||
"quantity_per_unit": "20 mg",
|
||||
"unit_price": 100,
|
||||
"units_in_stock": 50,
|
||||
"units_on_order": 0,
|
||||
"reorder_level": 10
|
||||
}
|
||||
?? status == 201
|
||||
|
||||
###
|
||||
{{
|
||||
const axios = require('axios');
|
||||
|
||||
let postData = {
|
||||
"id": 78,
|
||||
"product_name": "Saffaron",
|
||||
"discontinued": 0,
|
||||
"supplier_id": 12,
|
||||
"category_id": 2,
|
||||
"quantity_per_unit": "20 mg",
|
||||
"unit_price": 100,
|
||||
"units_in_stock": 50,
|
||||
"units_on_order": 0,
|
||||
"reorder_level": 10
|
||||
}
|
||||
const wait = axios.post(`${baseUrl}/products`, postData, {headers:{ 'Content-Type': 'application/json'} }).then(res => {
|
||||
return null;
|
||||
})
|
||||
exports.wait = wait;
|
||||
}}
|
||||
|
||||
PATCH {{baseUrl}}/products?id=eq.78
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"product_name": "Saffaron-patch"
|
||||
}
|
||||
?? status == 204
|
||||
|
||||
{{
|
||||
const {expect} = require('chai');
|
||||
const axios = require("axios");
|
||||
|
||||
const wait = axios.get(`${baseUrl}/products?id=eq.78`).then(res => {
|
||||
test("Check Patch", () =>
|
||||
{
|
||||
expect(res.data[0].product_name).to.equal("Saffaron-patch")
|
||||
})
|
||||
})
|
||||
exports.wait = wait;
|
||||
}}
|
||||
|
||||
###
|
||||
|
||||
{{
|
||||
const axios = require('axios');
|
||||
|
||||
let postData = {
|
||||
"id": 78,
|
||||
"product_name": "Saffaron",
|
||||
"discontinued": 0,
|
||||
"supplier_id": 12,
|
||||
"category_id": 2,
|
||||
"quantity_per_unit": "20 mg",
|
||||
"unit_price": 100,
|
||||
"units_in_stock": 50,
|
||||
"units_on_order": 0,
|
||||
"reorder_level": 10
|
||||
}
|
||||
const wait = axios.post(`${baseUrl}/products`, postData, {headers:{ 'Content-Type': 'application/json'} } ).then(res => {
|
||||
return null;
|
||||
})
|
||||
exports.wait = wait;
|
||||
}}
|
||||
|
||||
DELETE {{baseUrl}}/products?id=eq.78
|
||||
?? status == 204
|
||||
|
||||
{{
|
||||
const {expect} = require('chai');
|
||||
const axios = require("axios");
|
||||
|
||||
const wait = axios.get(`${baseUrl}/products`).then(res => {
|
||||
test("Check for Delete", () => {
|
||||
expect(res.data.length).to.equal(77);
|
||||
})
|
||||
})
|
||||
exports.wait = wait;
|
||||
}}
|
||||
Reference in New Issue
Block a user