mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
add base model unit test
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
import './components';
|
import './components';
|
||||||
|
import './models';
|
||||||
|
|||||||
25
awx/ui/test/unit/models/base.unit.js
Normal file
25
awx/ui/test/unit/models/base.unit.js
Normal 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'] });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
5
awx/ui/test/unit/models/index.js
Normal file
5
awx/ui/test/unit/models/index.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// Import angular and angular-mocks to the global scope
|
||||||
|
import 'angular-mocks';
|
||||||
|
|
||||||
|
// Import tests
|
||||||
|
import './base.unit';
|
||||||
Reference in New Issue
Block a user