Skip to content

Commit

Permalink
Reorganize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
toomuchdesign committed Jun 22, 2019
1 parent c17fec3 commit 0f0e921
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 204 deletions.
386 changes: 198 additions & 188 deletions src/__tests__/createCachedSelector.spec.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/cache/__tests__/deprecated/FifoCacheObject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {FifoCacheObject as CacheObject} from '../../../../src/index';

describe('FifoCacheObject (deprecated)', () => {
it('Should return "FifoObjectCache" class', () => {
it('returns "FifoObjectCache" class', () => {
expect(CacheObject.name).toBe('FifoObjectCache');
});
});
2 changes: 1 addition & 1 deletion src/cache/__tests__/deprecated/FlatCacheObject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {FlatCacheObject as CacheObject} from '../../../../src/index';

describe('FlatCacheObject (deprecated)', () => {
it('Should return "FlatObjectCache" class', () => {
it('returns "FlatObjectCache" class', () => {
expect(CacheObject.name).toBe('FlatObjectCache');
});
});
2 changes: 1 addition & 1 deletion src/cache/__tests__/deprecated/LruCacheObject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {LruCacheObject as CacheObject} from '../../../../src/index';

describe('LruCacheObject (deprecated)', () => {
it('Should return "LruMapCache" class', () => {
it('returns "LruMapCache" class', () => {
expect(CacheObject.name).toBe('LruMapCache');
});
});
6 changes: 3 additions & 3 deletions src/cache/__util__/testBasicBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fillCacheWith from './fillCacheWith';

function testBasicBehavior(CacheObject, options) {
describe('Cache basic behavior', () => {
it('Should return cached value', () => {
it('returns cached value', () => {
const cache = new CacheObject(options);
const actual = () => {};

Expand All @@ -12,7 +12,7 @@ function testBasicBehavior(CacheObject, options) {
expect(actual).toBe(expected);
});

it('Should remove a single item', () => {
it('removes a single item', () => {
const cache = new CacheObject(options);
const entries = [1, 2, 3, 4, 5];
fillCacheWith(cache, entries);
Expand All @@ -25,7 +25,7 @@ function testBasicBehavior(CacheObject, options) {
});
});

it('Should clear the cache', () => {
it('clears the cache', () => {
const cache = new CacheObject(options);
const entries = [1, 2, 3, 4, 5];
fillCacheWith(cache, entries);
Expand Down
6 changes: 3 additions & 3 deletions src/cache/__util__/testCacheSizeOptionValidation.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function testCacheSizeOptionValidation(CacheObject) {
describe('cacheSize option validation', () => {
it('Should throw error if not defined', () => {
it('throws error if not defined', () => {
expect(() => {
const cache = new CacheObject();
}).toThrow(/Missing/);
});

it('Should throw error if not a positive integer', () => {
it('throws error if not a positive integer', () => {
const wrongValues = [2.5, -12, 0];

wrongValues.forEach(value => {
Expand All @@ -16,7 +16,7 @@ function testCacheSizeOptionValidation(CacheObject) {
});
});

it('Should not throw if a positive integer', () => {
it("doesn't throw if a positive integer", () => {
expect(() => {
const cache = new CacheObject({cacheSize: 22});
}).not.toThrow();
Expand Down
4 changes: 2 additions & 2 deletions src/cache/__util__/testFifoBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fillCacheWith from './fillCacheWith';

function testFifoBehavior(CacheObject) {
describe('FIFO cache behavior', () => {
it('Should limit cache queue by removing the first added items', () => {
it('limits cache queue by removing the first added items', () => {
const cache = new CacheObject({cacheSize: 5});
const entries = [1, 2, 3, 4];
const newEntries = [5, 6, 7];
Expand All @@ -17,7 +17,7 @@ function testFifoBehavior(CacheObject) {
});
});

it('Should mantain cache updated after removing extraneous entry', () => {
it('mantains cache updated after removing extraneous entry', () => {
const cache = new CacheObject({cacheSize: 5});
const entries = [1, 2, 3, 4, 5];
fillCacheWith(cache, entries);
Expand Down
4 changes: 2 additions & 2 deletions src/cache/__util__/testLruBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fillCacheWith from './fillCacheWith';

function testLruBehavior(CacheObject) {
describe('LRU cache behavior', () => {
it('Should remove an item and update cache ordering when another is added', () => {
it('removes an item and update cache ordering when another is added', () => {
const cache = new CacheObject({cacheSize: 5});
const entries = [1, 2, 3, 4, 5];
fillCacheWith(cache, entries);
Expand All @@ -16,7 +16,7 @@ function testLruBehavior(CacheObject) {
});
});

it('Should limit cache queue by removing the least recently used item', () => {
it('limits cache queue by removing the least recently used item', () => {
const cache = new CacheObject({cacheSize: 5});

const entries = [0, 1, 2];
Expand Down
4 changes: 2 additions & 2 deletions src/cache/__util__/testMapCacheKeyBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import fillCacheWith from './fillCacheWith';
function testMapCacheKeyBehavior(CacheObject, options) {
describe('cacheKey', () => {
describe('isValidCacheKey method', () => {
it('Should not exist', () => {
it("doesn't not exist", () => {
const cache = new CacheObject(options);
expect(cache.isValidCacheKey).toBe(undefined);
});
});

it('Any kind of value should work as cache key', () => {
it('any kind of value works as cache key', () => {
const cache = new CacheObject(options);
const entries = new Set([1, {}, 3, [], null]);

Expand Down
2 changes: 1 addition & 1 deletion src/cache/__util__/testObjectCacheKeyBehavior.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function testObjectCacheKeyBehavior(CacheObject, options) {
describe('isValidCacheKey method', () => {
it('Should accept only numbers and string', () => {
it('accepts only numbers and string', () => {
const cache = new CacheObject(options);
const validValues = [1, 1.2, -5, 'foo', '12'];
const invalidValues = [{}, [], null, undefined, new Map()];
Expand Down

0 comments on commit 0f0e921

Please sign in to comment.