Merge branch 'hotfix/1.4.2' into develop

This commit is contained in:
Pranav Raj Sreepuram 2020-05-11 11:43:49 +05:30
commit 6e0f02a38b
3 changed files with 19 additions and 3 deletions

View file

@ -1,10 +1,10 @@
/* global axios */ /* global axios */
const API_VERSION = `/api/v1`; const DEFAULT_API_VERSION = 'v1';
class ApiClient { class ApiClient {
constructor(resource, options = {}) { constructor(resource, options = {}) {
this.apiVersion = API_VERSION; this.apiVersion = `/api/${options.apiVersion || DEFAULT_API_VERSION}`;
this.options = options; this.options = options;
this.resource = resource; this.resource = resource;
} }

View file

@ -3,7 +3,7 @@ import ApiClient from './ApiClient';
class ReportsAPI extends ApiClient { class ReportsAPI extends ApiClient {
constructor() { constructor() {
super('reports', { accountScoped: true }); super('reports', { accountScoped: true, apiVersion: 'v2' });
} }
getAccountReports(metric, since, until) { getAccountReports(metric, since, until) {

View file

@ -0,0 +1,16 @@
import reports from '../reports';
import ApiClient from '../ApiClient';
describe('#Reports API', () => {
it('creates correct instance', () => {
expect(reports).toBeInstanceOf(ApiClient);
expect(reports.apiVersion).toBe('/api/v2');
expect(reports).toHaveProperty('get');
expect(reports).toHaveProperty('show');
expect(reports).toHaveProperty('create');
expect(reports).toHaveProperty('update');
expect(reports).toHaveProperty('delete');
expect(reports).toHaveProperty('getAccountReports');
expect(reports).toHaveProperty('getAccountSummary');
});
});