harvest
Version:
Harvest API client library
48 lines • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const projects_1 = require("./projects");
const harvest = {
request: () => {
console.log('Request Made');
}
};
describe('Projects test', () => {
let instance;
let request;
let id = 1000;
beforeEach(() => {
instance = new projects_1.ProjectsAPI(harvest);
request = spyOn(instance.harvest, 'request');
});
it('Projects is instantiable', () => {
expect(instance).toBeInstanceOf(projects_1.ProjectsAPI);
});
it('should have a get method that calls the request method', () => {
instance.get(id);
expect(request).toBeCalledWith('GET', '/v2/projects/1000');
});
it('should have a list method that calls the request method', () => {
const query = { is_active: true };
instance.list(query);
expect(request).toBeCalledWith('GET', '/v2/projects', query);
});
it('should have a list method that calls the request method with a default set', () => {
instance.list();
expect(request).toBeCalledWith('GET', '/v2/projects', {});
});
it('should have an create method that calls the request method', () => {
const data = { property: true };
instance.create(data);
expect(request).toBeCalledWith('POST', '/v2/projects', data);
});
it('should have an update method that calls the request method', () => {
const query = { is_active: true };
instance.update(id, query);
expect(request).toBeCalledWith('PATCH', '/v2/projects/1000', query);
});
it('should have a delete method that calls the request method', () => {
instance.delete(id);
expect(request).toBeCalledWith('DELETE', '/v2/projects/1000');
});
});
//# sourceMappingURL=projects.spec.js.map