From 548594d1b0efd1fc57843451ebfa0d22fb302e0d Mon Sep 17 00:00:00 2001 From: luigisamurai Date: Tue, 19 Sep 2017 21:13:13 -0500 Subject: [PATCH 1/2] feat(GistsTest) Head, link request --- test/GistsTest.js | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/GistsTest.js b/test/GistsTest.js index 50b1a3c..5ed4aca 100644 --- a/test/GistsTest.js +++ b/test/GistsTest.js @@ -10,6 +10,54 @@ const githubAccount = { }; describe('Given a Github username', () => { + describe('when get all the public gists', () => { + let nextLink; + let allGitsFilterByGithub; + + before(async () => { + await request + .head(`${githubAccount.baseUrl}/gists`) + .end(function(err, res){ + nextLink = res.header.link; + }); + + allGitsFilterByGithub = await request + .get(`${githubAccount.baseUrl}/gists`); + }); + + it('then should exist a link', () => { + expect(nextLink).to.not.equal(undefined); + }); + + it('and return register should be thirty items', () => { + expect(allGitsFilterByGithub.body.length).to.equal(30); + }); + + describe('when accesses to second page', () => { + let firstGitsResponse; + let hundredGitsResponse; + let tenGitsResponse; + + before(async () => { + firstGitsResponse = await request + .get(`${githubAccount.baseUrl}/gists`) + .query({per_page: 10}); + + hundredGitsResponse = await request + .get(`${githubAccount.baseUrl}/gists`) + .query({per_page: 100}); + }); + + it('then the body should contain ten items', () => { + expect(firstGitsResponse.body.length).to.equal(10); + }); + + it('and the body should contain one hundred items', () => { + expect(hundredGitsResponse.body.length).to.equal(100); + }); + }); + }); + describe('when it creates a Gits', () => { let createGitsResponse; let gist; From 5593bf35f2f889209487121c351b6a6508db08d9 Mon Sep 17 00:00:00 2001 From: luigisamurai Date: Tue, 19 Sep 2017 21:22:21 -0500 Subject: [PATCH 2/2] feat(GistsTest) Head, link request --- test/GistsTest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/GistsTest.js b/test/GistsTest.js index 5ed4aca..2820301 100644 --- a/test/GistsTest.js +++ b/test/GistsTest.js @@ -33,7 +33,7 @@ describe('Given a Github username', () => { expect(allGitsFilterByGithub.body.length).to.equal(30); }); - describe('when accesses to second page', () => { + describe('when it filters the items', () => { let firstGitsResponse; let hundredGitsResponse; let tenGitsResponse;