diff --git a/front/core/components/crud-model/index.spec.js b/front/core/components/crud-model/index.spec.js index 4e2ee311e..8233c5992 100644 --- a/front/core/components/crud-model/index.spec.js +++ b/front/core/components/crud-model/index.spec.js @@ -142,16 +142,6 @@ describe('Component vnCrudModel', () => { }); }); - xdescribe('cancelRequest()', () => { - it('should check the resolve method is called and canceler is null', () => { - controller.canceler = {resolve: () => {}}; - spyOn(controller.canceler, 'resolve'); - controller.cancelRequest(); - - expect(controller.canceler).toBe(null); - }); - }); - describe('loadMore()', () => { it('should call sendRequest with the new filter', () => { spyOn(controller, 'sendRequest'); @@ -175,17 +165,6 @@ describe('Component vnCrudModel', () => { }); }); - // describe('buildParams()', () => { - // it('', () => { - // // spyOn(controller, 'autoRefresh'); - // // spyOn(controller, 'clear'); - - // // controller.url = '/TestUrl'; - - // // expect(controller.url).toEqual('/TestUrl'); - // }); - // }); - describe('refresh()', () => { it('shold resolve a fake promise if this._url is undefined', () => { spyOn(controller.$q, 'resolve'); @@ -199,7 +178,7 @@ describe('Component vnCrudModel', () => { }); describe('onRemoteDone()', () => { - it('', () => { + it('should check onRequestEnd is called, moreRows is true and currentFilter is undefined when append is true', () => { spyOn(controller, 'onRequestEnd'); const json = {data: [ @@ -211,6 +190,23 @@ describe('Component vnCrudModel', () => { controller.onRemoteDone(json, filter, true); expect(controller.moreRows).toBe(true); + expect(controller.filter).toBeUndefined(); + expect(controller.onRequestEnd).toHaveBeenCalledWith(); + }); + + it('should check onRequestEnd is called, moreRows is true and currentFilter is defined when append is false', () => { + spyOn(controller, 'onRequestEnd'); + + const json = {data: [ + { + id: 1, + name: 'test' + }]}; + const filter = {limit: 1}; + controller.onRemoteDone(json, filter, false); + + expect(controller.moreRows).toBe(true); + expect(controller.currentFilter).toBe(filter); expect(controller.onRequestEnd).toHaveBeenCalledWith(); }); }); @@ -221,12 +217,14 @@ describe('Component vnCrudModel', () => { let error; try { - controller.onRemoteError('TestError'); + const newError = new Error('TestError'); + controller.onRemoteError(newError); } catch (e) { error = e.message; } - expect(error).toBe('errasdor'); + expect(controller.onRequestEnd).toHaveBeenCalledWith(); + expect(error).toEqual('TestError'); }); }); });