add base model unit test

This commit is contained in:
Jake McDermott 2017-12-07 13:45:23 -05:00
parent 78b975b2a9
commit c40feb52b7
No known key found for this signature in database
GPG Key ID: 3B02CAD476EECB35
3 changed files with 31 additions and 1 deletions

View File

@ -1,2 +1,2 @@
import './components';
import './models';

View File

@ -0,0 +1,25 @@
describe('Models | BaseModel', () => {
let baseModel;
beforeEach(() => {
angular.mock.module('at.lib.services');
angular.mock.module('at.lib.models');
});
beforeEach(angular.mock.inject(($injector) => {
baseModel = new ($injector.get('BaseModel'))('test');
}));
describe('parseRequestConfig', () => {
it('always returns the expected configuration', () => {
const { parseRequestConfig } = baseModel;
const data = { name: 'foo' };
expect(parseRequestConfig('get')).toEqual({ method: 'get', resource: undefined });
expect(parseRequestConfig('get', 1)).toEqual({ method: 'get', resource: 1 });
expect(parseRequestConfig('post', { data })).toEqual({ method: 'post', data });
expect(parseRequestConfig(['get', 'post'], [1, 2], { data }))
.toEqual({ resource: [1, 2], method: ['get', 'post'] });
});
});
});

View File

@ -0,0 +1,5 @@
// Import angular and angular-mocks to the global scope
import 'angular-mocks';
// Import tests
import './base.unit';