async-selector
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -814,2 +814,36 @@ import createAsyncSelector from '../src/index'; | ||
}, 200); | ||
}); | ||
test('Throw error', () => { | ||
try { | ||
createAsyncSelector(); | ||
} catch (e) { | ||
expect(e.message).toBe('An object of parameters must be passed in'); | ||
} | ||
}); | ||
test('selector.getResult', done => { | ||
let c = 0; | ||
let state = {employees: ['Mark Metzger'], maxAge: 10}; | ||
const ages = createAsyncSelector(params2, s => s.employees, s => s.maxAge); | ||
const result = ages(state); | ||
const expected = { | ||
value: [], | ||
previous: [], | ||
isWaiting: false, | ||
isResolved: true, | ||
isRejected: false, | ||
} | ||
ages(state); | ||
setTimeout(() => { | ||
try { | ||
expect(deepEqual(ages.getResult(), expected)).toBe(true); | ||
} catch (e) { | ||
done.fail(e) | ||
} | ||
done(); | ||
}, 200); | ||
}); |
@@ -13,9 +13,9 @@ 'use strict'; | ||
if ((typeof params === 'undefined' ? 'undefined' : _typeof(params)) !== 'object' || params === null) { | ||
throw new Exception('An object of parameters must be passed in'); | ||
throw new Error('An object of parameters must be passed in'); | ||
} | ||
if (typeof params.sync !== 'function') { | ||
throw new Exception('Looking for a function called "sync". This function is called to before the promise resolves'); | ||
throw new Error('Looking for a function called "sync". This function is called to before the promise resolves'); | ||
} | ||
if (typeof params.async !== 'function') { | ||
throw new Exception('Looking for a function called "async". This function returns a promise which handles asynchronous code'); | ||
throw new Error('Looking for a function called "async". This function returns a promise which handles asynchronous code'); | ||
} | ||
@@ -130,2 +130,5 @@ } | ||
}; | ||
func.getResult = function () { | ||
return memoizedResult; | ||
}; | ||
return func; | ||
@@ -132,0 +135,0 @@ } |
{ | ||
"name": "async-selector", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "Select values from databases using asynchronous selectors.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
145297
970