simplifies assignment of default options
This commit is contained in:
parent
269adbf9db
commit
45b2c63fdf
2 changed files with 4 additions and 3 deletions
|
@ -32,9 +32,8 @@ import httpStatusCodes from './http_status';
|
|||
*/
|
||||
export default class Poll {
|
||||
constructor(options = {}) {
|
||||
this.options = Object.assign({}, {
|
||||
data: {},
|
||||
}, options);
|
||||
this.options = options;
|
||||
this.options.data = options.data || {};
|
||||
|
||||
this.intervalHeader = 'POLL-INTERVAL';
|
||||
}
|
||||
|
|
|
@ -109,12 +109,14 @@ describe('Poll', () => {
|
|||
new Poll({
|
||||
resource: service,
|
||||
method: 'fetch',
|
||||
data: { page: 1 },
|
||||
successCallback: callbacks.success,
|
||||
errorCallback: callbacks.error,
|
||||
}).makeRequest();
|
||||
|
||||
setTimeout(() => {
|
||||
expect(service.fetch.calls.count()).toEqual(2);
|
||||
expect(service.fetch).toHaveBeenCalledWith({ page: 1 });
|
||||
expect(callbacks.success).toHaveBeenCalled();
|
||||
expect(callbacks.error).not.toHaveBeenCalled();
|
||||
done();
|
||||
|
|
Loading…
Reference in a new issue