simplifies assignment of default options

This commit is contained in:
Filipa Lacerda 2017-03-22 12:37:38 +00:00
parent 269adbf9db
commit 45b2c63fdf
2 changed files with 4 additions and 3 deletions

View File

@ -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';
}

View File

@ -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();