Commit 45b2c63f authored by Filipa Lacerda's avatar Filipa Lacerda

simplifies assignment of default options

parent 269adbf9
...@@ -32,9 +32,8 @@ import httpStatusCodes from './http_status'; ...@@ -32,9 +32,8 @@ import httpStatusCodes from './http_status';
*/ */
export default class Poll { export default class Poll {
constructor(options = {}) { constructor(options = {}) {
this.options = Object.assign({}, { this.options = options;
data: {}, this.options.data = options.data || {};
}, options);
this.intervalHeader = 'POLL-INTERVAL'; this.intervalHeader = 'POLL-INTERVAL';
} }
......
...@@ -109,12 +109,14 @@ describe('Poll', () => { ...@@ -109,12 +109,14 @@ describe('Poll', () => {
new Poll({ new Poll({
resource: service, resource: service,
method: 'fetch', method: 'fetch',
data: { page: 1 },
successCallback: callbacks.success, successCallback: callbacks.success,
errorCallback: callbacks.error, errorCallback: callbacks.error,
}).makeRequest(); }).makeRequest();
setTimeout(() => { setTimeout(() => {
expect(service.fetch.calls.count()).toEqual(2); expect(service.fetch.calls.count()).toEqual(2);
expect(service.fetch).toHaveBeenCalledWith({ page: 1 });
expect(callbacks.success).toHaveBeenCalled(); expect(callbacks.success).toHaveBeenCalled();
expect(callbacks.error).not.toHaveBeenCalled(); expect(callbacks.error).not.toHaveBeenCalled();
done(); done();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment