From 8e9fecf99a103be53b463ed63c31a09f2550c5b8 Mon Sep 17 00:00:00 2001 From: alibw Date: Mon, 11 Nov 2024 15:42:31 +0330 Subject: [PATCH] Added select tests --- Select.http | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Select.http diff --git a/Select.http b/Select.http new file mode 100644 index 0000000..62a3a35 --- /dev/null +++ b/Select.http @@ -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)); + }); +}} +