提交 45b2c63f 编写于 作者: F Filipa Lacerda

simplifies assignment of default options

上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册