Skip to content

Commit

Permalink
feat(test): add response headers tests
Browse files Browse the repository at this point in the history
  • Loading branch information
muuvmuuv committed Jan 2, 2024
1 parent 34656f3 commit 77ee031
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions projects/ngneat/cashew/src/lib/specs/local-storage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { httpResponse, localStorageMock } from './mocks';
import { HttpCacheLocalStorage } from '../local-storage/local-storage-cache';
import { HttpHeaders, HttpResponse } from '@angular/common/http';

describe('httpCacheLocalStorage', () => {
let storage: HttpCacheLocalStorage;
Expand Down Expand Up @@ -28,6 +29,12 @@ describe('httpCacheLocalStorage', () => {
expect(storage.get(existingKey)).toBe(response);
});

it('should get the cached response headers', () => {
const { headers } = storage.get(existingKey) as HttpResponse<any>;
expect(headers).toBeInstanceOf(HttpHeaders);
expect(headers).toBe(response.headers);
});

it('should not access local storage when key is found in memory', () => {
jest.spyOn(localStorage, 'setItem');
const value = storage.get(existingKey);
Expand Down

0 comments on commit 77ee031

Please sign in to comment.