From 830354b2461f03d580c0a3f7859e6f9d2b55b3c0 Mon Sep 17 00:00:00 2001 From: alibw <69758323+alibw@users.noreply.github.com> Date: Sun, 3 Sep 2023 12:15:29 +0330 Subject: [PATCH 1/7] Added : Count & Pagination --- Count.http | 15 +++++++++++++++ Pagination.http | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Count.http create mode 100644 Pagination.http diff --git a/Count.http b/Count.http new file mode 100644 index 0000000..a036edd --- /dev/null +++ b/Count.http @@ -0,0 +1,15 @@ +{{ + const { equal } = require('assert'); +}} + +GET {{baseUrl}}/products +Prefer: count=exact +?? status == 200 +{{ + const { equal } = require('assert'); + let responseItems = JSON. parse(response.body); + let itemsCount = responseItems.length; + test('OK content-range', () => { + equal(response.headers['content-range'], `0-${itemsCount - 1}/${itemsCount}`); + }); +}} \ No newline at end of file diff --git a/Pagination.http b/Pagination.http new file mode 100644 index 0000000..4efec9d --- /dev/null +++ b/Pagination.http @@ -0,0 +1,21 @@ +GET {{baseUrl}}/products?limit=20 +?? status == 200 +{{ + const { equal } = require('assert'); + let responseItems = JSON. parse(response.body); + let itemsCount = responseItems.length; + test('OK content-range', () => { + equal(response.headers['content-range'], `0-${itemsCount - 1}/*`); + }); +}} + +GET {{baseUrl}}/products?limit=20&offset=20 +?? status == 200 +{{ + const { equal } = require('assert'); + let responseItems = JSON. parse(response.body); + let itemsCount = responseItems.length; + test('OK content-range', () => { + equal(response.headers['content-range'], `${itemsCount}-${itemsCount - 1 + 20}/*`); + }); +}} \ No newline at end of file From 192bdbb43a35336bb4c27624183f1c534226fe63 Mon Sep 17 00:00:00 2001 From: alibw <69758323+alibw@users.noreply.github.com> Date: Sun, 3 Sep 2023 16:36:09 +0330 Subject: [PATCH 2/7] Update Pagination.http Fixed --- Pagination.http | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pagination.http b/Pagination.http index 4efec9d..7a34fff 100644 --- a/Pagination.http +++ b/Pagination.http @@ -9,13 +9,13 @@ GET {{baseUrl}}/products?limit=20 }); }} -GET {{baseUrl}}/products?limit=20&offset=20 +GET {{baseUrl}}/products?limit=40&offset=7 ?? status == 200 {{ const { equal } = require('assert'); let responseItems = JSON. parse(response.body); let itemsCount = responseItems.length; test('OK content-range', () => { - equal(response.headers['content-range'], `${itemsCount}-${itemsCount - 1 + 20}/*`); + equal(response.headers['content-range'], '7-46/*'); }); }} \ No newline at end of file From 4fbf806fe2318d98257b4cefd9e8011540c10052 Mon Sep 17 00:00:00 2001 From: alibw <69758323+alibw@users.noreply.github.com> Date: Sun, 3 Sep 2023 16:36:26 +0330 Subject: [PATCH 3/7] Update Count.http Added : without prefer header test --- Count.http | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Count.http b/Count.http index a036edd..06c7a48 100644 --- a/Count.http +++ b/Count.http @@ -1,7 +1,3 @@ -{{ - const { equal } = require('assert'); -}} - GET {{baseUrl}}/products Prefer: count=exact ?? status == 200 @@ -12,4 +8,15 @@ Prefer: count=exact test('OK content-range', () => { equal(response.headers['content-range'], `0-${itemsCount - 1}/${itemsCount}`); }); +}} + +GET {{baseUrl}}/products +?? status == 200 +{{ + const { equal } = require('assert'); + let responseItems = JSON. parse(response.body); + let itemsCount = responseItems.length; + test('OK content-range', () => { + equal(response.headers['content-range'], `0-${itemsCount - 1}/*`); + }); }} \ No newline at end of file From 56409a9fefbf3181a42d223d991b0f46d68389c1 Mon Sep 17 00:00:00 2001 From: alibw <69758323+alibw@users.noreply.github.com> Date: Sun, 3 Sep 2023 16:40:43 +0330 Subject: [PATCH 4/7] Update Pagination.http Removed : unused --- Pagination.http | 2 -- 1 file changed, 2 deletions(-) diff --git a/Pagination.http b/Pagination.http index 7a34fff..7d81cd0 100644 --- a/Pagination.http +++ b/Pagination.http @@ -13,8 +13,6 @@ GET {{baseUrl}}/products?limit=40&offset=7 ?? status == 200 {{ const { equal } = require('assert'); - let responseItems = JSON. parse(response.body); - let itemsCount = responseItems.length; test('OK content-range', () => { equal(response.headers['content-range'], '7-46/*'); }); From 6b856fdf740bf353f5be27c69ee4ee24f9e887e6 Mon Sep 17 00:00:00 2001 From: alibw <69758323+alibw@users.noreply.github.com> Date: Sun, 3 Sep 2023 16:51:54 +0330 Subject: [PATCH 5/7] Added : prefer header test --- Pagination.http | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Pagination.http b/Pagination.http index 7d81cd0..49b52ec 100644 --- a/Pagination.http +++ b/Pagination.http @@ -16,4 +16,16 @@ GET {{baseUrl}}/products?limit=40&offset=7 test('OK content-range', () => { equal(response.headers['content-range'], '7-46/*'); }); -}} \ No newline at end of file +}} + +GET {{baseUrl}}/products?limit=20&offset=40 +Prefer: count=exact +?? status == 206 +{{ + const { equal } = require('assert'); + let responseItems = JSON. parse(response.body); + let itemsCount = responseItems.length; + test('OK content-range', () => { + equal(response.headers['content-range'], '40-59/77'); + }); +}} From 8cd4c874981f65db588967e696195c6c50c08296 Mon Sep 17 00:00:00 2001 From: alibw <69758323+alibw@users.noreply.github.com> Date: Sun, 3 Sep 2023 17:27:30 +0330 Subject: [PATCH 6/7] Removed : unused --- Pagination.http | 2 -- 1 file changed, 2 deletions(-) diff --git a/Pagination.http b/Pagination.http index 49b52ec..0596639 100644 --- a/Pagination.http +++ b/Pagination.http @@ -23,8 +23,6 @@ Prefer: count=exact ?? status == 206 {{ const { equal } = require('assert'); - let responseItems = JSON. parse(response.body); - let itemsCount = responseItems.length; test('OK content-range', () => { equal(response.headers['content-range'], '40-59/77'); }); From 00e11019630d2cff84e059d4b2fa5a103660bef5 Mon Sep 17 00:00:00 2001 From: alibw <69758323+alibw@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:41:15 +0330 Subject: [PATCH 7/7] Changed : changes needed for prescript and httpyac.json file --- Count.http | 14 ++++++++------ Pagination.http | 20 +++++++++++--------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Count.http b/Count.http index 06c7a48..412bcaf 100644 --- a/Count.http +++ b/Count.http @@ -1,22 +1,24 @@ -GET {{baseUrl}}/products +# @import ./PreScript.http +### +GET /products Prefer: count=exact ?? status == 200 {{ - const { equal } = require('assert'); + const { expect } = require('chai'); let responseItems = JSON. parse(response.body); let itemsCount = responseItems.length; test('OK content-range', () => { - equal(response.headers['content-range'], `0-${itemsCount - 1}/${itemsCount}`); + expect(response.headers['content-range']).to.equal(`0-${itemsCount - 1}/${itemsCount}`); }); }} -GET {{baseUrl}}/products +GET /products ?? status == 200 {{ - const { equal } = require('assert'); + const { expect } = require('chai'); let responseItems = JSON. parse(response.body); let itemsCount = responseItems.length; test('OK content-range', () => { - equal(response.headers['content-range'], `0-${itemsCount - 1}/*`); + expect(response.headers['content-range']).to.equal(`0-${itemsCount - 1}/*`); }); }} \ No newline at end of file diff --git a/Pagination.http b/Pagination.http index 0596639..1007ba1 100644 --- a/Pagination.http +++ b/Pagination.http @@ -1,29 +1,31 @@ -GET {{baseUrl}}/products?limit=20 +# @import ./PreScript.http +### +GET /products?limit=20 ?? status == 200 {{ - const { equal } = require('assert'); + const { expect } = require('chai'); let responseItems = JSON. parse(response.body); let itemsCount = responseItems.length; test('OK content-range', () => { - equal(response.headers['content-range'], `0-${itemsCount - 1}/*`); + expect(response.headers['content-range']).to.equal(`0-${itemsCount - 1}/*`); }); }} -GET {{baseUrl}}/products?limit=40&offset=7 +GET /products?limit=40&offset=7 ?? status == 200 {{ - const { equal } = require('assert'); + const { expect } = require('chai'); test('OK content-range', () => { - equal(response.headers['content-range'], '7-46/*'); + expect(response.headers['content-range']).to.equal('7-46/*'); }); }} -GET {{baseUrl}}/products?limit=20&offset=40 +GET /products?limit=20&offset=40 Prefer: count=exact ?? status == 206 {{ - const { equal } = require('assert'); + const { expect } = require('chai'); test('OK content-range', () => { - equal(response.headers['content-range'], '40-59/77'); + expect(response.headers['content-range']).to.equal('40-59/77'); }); }}