fixed lint errors

This commit is contained in:
William Welling
2017-07-13 11:19:02 -05:00
parent 75cb60e70f
commit 066bba28af
123 changed files with 1295 additions and 1407 deletions

View File

@@ -1,9 +1,10 @@
import * as deepFreeze from "deep-freeze";
import { objectCacheReducer } from "./object-cache.reducer";
import * as deepFreeze from 'deep-freeze';
import { objectCacheReducer } from './object-cache.reducer';
import {
AddToObjectCacheAction,
RemoveFromObjectCacheAction, ResetObjectCacheTimestampsAction
} from "./object-cache.actions";
} from './object-cache.actions';
class NullAction extends RemoveFromObjectCacheAction {
type = null;
@@ -14,51 +15,51 @@ class NullAction extends RemoveFromObjectCacheAction {
}
}
describe("objectCacheReducer", () => {
describe('objectCacheReducer', () => {
const uuid1 = '1698f1d3-be98-4c51-9fd8-6bfedcbd59b7';
const uuid2 = '28b04544-1766-4e82-9728-c4e93544ecd3';
const testState = {
[uuid1]: {
data: {
uuid: uuid1,
foo: "bar"
foo: 'bar'
},
timeAdded: new Date().getTime(),
msToLive: 900000,
requestHref: "https://rest.api/endpoint/uuid1"
requestHref: 'https://rest.api/endpoint/uuid1'
},
[uuid2]: {
data: {
uuid: uuid2,
foo: "baz"
foo: 'baz'
},
timeAdded: new Date().getTime(),
msToLive: 900000,
requestHref: "https://rest.api/endpoint/uuid2"
requestHref: 'https://rest.api/endpoint/uuid2'
}
};
deepFreeze(testState);
it("should return the current state when no valid actions have been made", () => {
it('should return the current state when no valid actions have been made', () => {
const action = new NullAction();
const newState = objectCacheReducer(testState, action);
expect(newState).toEqual(testState);
});
it("should start with an empty cache", () => {
it('should start with an empty cache', () => {
const action = new NullAction();
const initialState = objectCacheReducer(undefined, action);
expect(initialState).toEqual(Object.create(null));
});
it("should add the payload to the cache in response to an ADD action", () => {
it('should add the payload to the cache in response to an ADD action', () => {
const state = Object.create(null);
const objectToCache = { uuid: uuid1 };
const timeAdded = new Date().getTime();
const msToLive = 900000;
const requestHref = "https://rest.api/endpoint/uuid1";
const requestHref = 'https://rest.api/endpoint/uuid1';
const action = new AddToObjectCacheAction(objectToCache, timeAdded, msToLive, requestHref);
const newState = objectCacheReducer(state, action);
@@ -67,31 +68,33 @@ describe("objectCacheReducer", () => {
expect(newState[uuid1].msToLive).toEqual(msToLive);
});
it("should overwrite an object in the cache in response to an ADD action if it already exists", () => {
const objectToCache = { uuid: uuid1, foo: "baz", somethingElse: true };
it('should overwrite an object in the cache in response to an ADD action if it already exists', () => {
const objectToCache = { uuid: uuid1, foo: 'baz', somethingElse: true };
const timeAdded = new Date().getTime();
const msToLive = 900000;
const requestHref = "https://rest.api/endpoint/uuid1";
const requestHref = 'https://rest.api/endpoint/uuid1';
const action = new AddToObjectCacheAction(objectToCache, timeAdded, msToLive, requestHref);
const newState = objectCacheReducer(testState, action);
expect(newState[uuid1].data['foo']).toBe("baz");
/* tslint:disable:no-string-literal */
expect(newState[uuid1].data['foo']).toBe('baz');
expect(newState[uuid1].data['somethingElse']).toBe(true);
/* tslint:enable:no-string-literal */
});
it("should perform the ADD action without affecting the previous state", () => {
it('should perform the ADD action without affecting the previous state', () => {
const state = Object.create(null);
const objectToCache = { uuid: uuid1 };
const timeAdded = new Date().getTime();
const msToLive = 900000;
const requestHref = "https://rest.api/endpoint/uuid1";
const requestHref = 'https://rest.api/endpoint/uuid1';
const action = new AddToObjectCacheAction(objectToCache, timeAdded, msToLive, requestHref);
deepFreeze(state);
objectCacheReducer(state, action);
});
it("should remove the specified object from the cache in response to the REMOVE action", () => {
it('should remove the specified object from the cache in response to the REMOVE action', () => {
const action = new RemoveFromObjectCacheAction(uuid1);
const newState = objectCacheReducer(testState, action);
@@ -108,13 +111,13 @@ describe("objectCacheReducer", () => {
expect(newState).toEqual(testState);
});
it("should perform the REMOVE action without affecting the previous state", () => {
it('should perform the REMOVE action without affecting the previous state', () => {
const action = new RemoveFromObjectCacheAction(uuid1);
//testState has already been frozen above
// testState has already been frozen above
objectCacheReducer(testState, action);
});
it("should set the timestamp of all objects in the cache in response to a RESET_TIMESTAMPS action", () => {
it('should set the timestamp of all objects in the cache in response to a RESET_TIMESTAMPS action', () => {
const newTimestamp = new Date().getTime();
const action = new ResetObjectCacheTimestampsAction(newTimestamp);
const newState = objectCacheReducer(testState, action);
@@ -123,9 +126,9 @@ describe("objectCacheReducer", () => {
});
});
it("should perform the RESET_TIMESTAMPS action without affecting the previous state", () => {
it('should perform the RESET_TIMESTAMPS action without affecting the previous state', () => {
const action = new ResetObjectCacheTimestampsAction(new Date().getTime());
//testState has already been frozen above
// testState has already been frozen above
objectCacheReducer(testState, action);
});