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';
*/
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();
......
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