Files
2024-07-16 17:43:16 +10:00

22 lines
581 B
TypeScript

import StatsReport, { SITE } from '../src';
test('should report data', () => {
let xhrMock = {
open: jest.fn(),
setRequestHeader: jest.fn(),
onreadystatechange: jest.fn(),
send: jest.fn(),
readyState: 4,
responseText: '',
status: 200
};
(window as any).XMLHttpRequest = jest.fn(() => xhrMock)
const stats = new StatsReport(SITE.rabby);
stats.report('testStats', {
value: 1,
data: 'test',
bool: true,
});
expect(xhrMock.open).toBeCalledWith('GET', 'https://festats.debank.com/rabby/testStats?value=1&data=test&bool=true');
});