UNPKG

angular-cached-resource

Version:

An AngularJS module to interact with RESTful resources, even when browser is offline

22 lines (17 loc) 864 B
describe 'an existing write queue', -> {$cachedResource, $httpBackend} = {} beforeEach -> localStorage.setItem 'cachedResource://existing-write-queue-test/write', angular.toJson [{params: {id: 1}, action: 'save'}] localStorage.setItem 'cachedResource://existing-write-queue-test?id=1', angular.toJson value: magic: 'from the cache' module('ngCachedResource') inject ($injector) -> $cachedResource = $injector.get '$cachedResource' $httpBackend = $injector.get '$httpBackend' afterEach -> $httpBackend.verifyNoOutstandingExpectation() $httpBackend.verifyNoOutstandingRequest() localStorage.clear() it 'saves the item that was stored in the cache', -> $httpBackend.expectPOST('/mock/1', magic: 'from the cache').respond 200 $cachedResource 'existing-write-queue-test', '/mock/:id' $httpBackend.flush()