@rocketmakers/api-swr
Version:
Rocketmakers front-end library for parsing a generated Typescript API client into a set of configurable React hooks for fetching and mutating data.
48 lines (47 loc) • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const mocking_1 = require("./mocking");
describe('createMockAxiosResponse', () => {
it('should return a correct response object when executed', () => {
const data = { key: 'value' };
const response = (0, mocking_1.createMockAxiosResponse)({ data });
expect(response).toEqual({
data,
status: 200,
statusText: 'OK',
headers: {},
config: {
headers: {},
},
});
});
});
describe('createSuccessResponse', () => {
it('should return a correct success response object when executed', () => {
const data = { key: 'value' };
const response = (0, mocking_1.createMockAxiosSuccessResponse)(data);
expect(response).toEqual({
data,
status: 200,
statusText: 'OK',
headers: {},
config: {
headers: {},
},
});
});
});
describe('createErrorResponse', () => {
it('should return a correct error response object when executed', () => {
const response = (0, mocking_1.createMockAxiosErrorResponse)();
expect(response).toEqual({
data: {},
status: 500,
statusText: 'Error',
headers: {},
config: {
headers: {},
},
});
});
});