Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('makes a get request with the provided params', () => {
Request.query = jest.fn().mockReturnThis();
Poller({
url,
data: {
foo: 'bar',
headers: {
Accept: 'application/json'
}
}
}, functions, { interval: 1000 });
expect(Request.query).toBeCalledWith({
foo: 'bar',
headers: {
Accept: 'application/json'
}
});
it('calls the correct query', () => {
Request.query = jest.fn().mockReturnThis();
instance.ajaxUpdateList = jest.fn();
instance.getData("foo", 1);
expect(Request.query).toBeCalledWith({
page: 1,
rows: 25,
value: 'foo'
});
});
it('queries for the data after 250ms', () => {
Request.query = jest.fn().mockReturnThis();
instance.emitOnChangeCallback('data', options);
expect(Request.query.mock.calls.length).toBe(0);
jest.runTimersToTime(251);
expect(Request.query).toBeCalledWith('page=1&rows=10');
});