From 490366ff660b78d0b083f49c03a73536e173aae7 Mon Sep 17 00:00:00 2001 From: Douglas Paz Date: Mon, 9 Jul 2018 13:38:16 -0300 Subject: [PATCH] Fix #108 --- src/api/utils/List.js | 1 + src/api/utils/List.test.js | 41 +++++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/api/utils/List.js b/src/api/utils/List.js index a346d35f2..77cb9924a 100644 --- a/src/api/utils/List.js +++ b/src/api/utils/List.js @@ -45,6 +45,7 @@ export default class List { async reset() { this.items = []; + this.deletions = []; this.nextEntryPoint = this.initial; } diff --git a/src/api/utils/List.test.js b/src/api/utils/List.test.js index 60ed7d8c0..bbfa9d2da 100644 --- a/src/api/utils/List.test.js +++ b/src/api/utils/List.test.js @@ -5,10 +5,41 @@ jest.mock('../request'); import List from './List'; describe('API List', () => { - test('repositories test', async () => { - const list = new List('/repositories/'); - await list.next(); - expect(list.items).toHaveLength(20); - expect(list.hasNext).toBeTruthy(); + let list; + const initial = '/repositories/'; + beforeEach(() => { + list = new List(initial); + }); + + describe('next', () => { + beforeEach(async () => { + await list.next(); + }); + + test('has items', () => { + expect(list.items).toHaveLength(20); + }); + + test('has next', () => { + expect(list.hasNext).toBeTruthy(); + }); + + describe('reset', () => { + beforeEach(() => { + list.reset(); + }); + + test('nextEntryPoint is initial', () => { + expect(list.nextEntryPoint).toBe(initial); + }); + + test('empty items', () => { + expect(list.items).toHaveLength(0); + }); + + test('empty deletions', () => { + expect(list.deletions).toHaveLength(0); + }); + }); }); });