mirror of
https://github.com/ansible/awx.git
synced 2026-03-18 01:17:35 -02:30
Fixed unit tests after labels changes
This commit is contained in:
@@ -10,14 +10,14 @@ describe('Controller: WorkflowAdd', () => {
|
|||||||
GenerateForm,
|
GenerateForm,
|
||||||
TemplatesService,
|
TemplatesService,
|
||||||
q,
|
q,
|
||||||
getLabelsDeferred,
|
|
||||||
createWorkflowJobTemplateDeferred,
|
createWorkflowJobTemplateDeferred,
|
||||||
httpBackend,
|
httpBackend,
|
||||||
ProcessErrors,
|
ProcessErrors,
|
||||||
CreateSelect2,
|
CreateSelect2,
|
||||||
Wait,
|
Wait,
|
||||||
ParseTypeChange,
|
ParseTypeChange,
|
||||||
ToJSON;
|
ToJSON,
|
||||||
|
availableLabels;
|
||||||
|
|
||||||
beforeEach(angular.mock.module('Tower'));
|
beforeEach(angular.mock.module('Tower'));
|
||||||
beforeEach(angular.mock.module('RestServices'));
|
beforeEach(angular.mock.module('RestServices'));
|
||||||
@@ -45,6 +45,11 @@ describe('Controller: WorkflowAdd', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
availableLabels = [{
|
||||||
|
name: "foo",
|
||||||
|
id: "1"
|
||||||
|
}];
|
||||||
|
|
||||||
ClearScope = jasmine.createSpy('ClearScope');
|
ClearScope = jasmine.createSpy('ClearScope');
|
||||||
Alert = jasmine.createSpy('Alert');
|
Alert = jasmine.createSpy('Alert');
|
||||||
ProcessErrors = jasmine.createSpy('ProcessErrors');
|
ProcessErrors = jasmine.createSpy('ProcessErrors');
|
||||||
@@ -62,9 +67,10 @@ describe('Controller: WorkflowAdd', () => {
|
|||||||
$provide.value('Wait', Wait);
|
$provide.value('Wait', Wait);
|
||||||
$provide.value('ParseTypeChange', ParseTypeChange);
|
$provide.value('ParseTypeChange', ParseTypeChange);
|
||||||
$provide.value('ToJSON', ToJSON);
|
$provide.value('ToJSON', ToJSON);
|
||||||
|
$provide.value('availableLabels', availableLabels);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(angular.mock.inject( ($rootScope, $controller, $q, $httpBackend, _state_, _ConfigService_, _ClearScope_, _GetChoices_, _Alert_, _GenerateForm_, _ProcessErrors_, _CreateSelect2_, _Wait_, _ParseTypeChange_, _ToJSON_) => {
|
beforeEach(angular.mock.inject( ($rootScope, $controller, $q, $httpBackend, _state_, _ConfigService_, _ClearScope_, _GetChoices_, _Alert_, _GenerateForm_, _ProcessErrors_, _CreateSelect2_, _Wait_, _ParseTypeChange_, _ToJSON_, _availableLabels_) => {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
state = _state_;
|
state = _state_;
|
||||||
q = $q;
|
q = $q;
|
||||||
@@ -75,10 +81,10 @@ describe('Controller: WorkflowAdd', () => {
|
|||||||
ProcessErrors = _ProcessErrors_;
|
ProcessErrors = _ProcessErrors_;
|
||||||
CreateSelect2 = _CreateSelect2_;
|
CreateSelect2 = _CreateSelect2_;
|
||||||
Wait = _Wait_;
|
Wait = _Wait_;
|
||||||
getLabelsDeferred = q.defer();
|
|
||||||
createWorkflowJobTemplateDeferred = q.defer();
|
createWorkflowJobTemplateDeferred = q.defer();
|
||||||
ParseTypeChange = _ParseTypeChange_;
|
ParseTypeChange = _ParseTypeChange_;
|
||||||
ToJSON = _ToJSON_;
|
ToJSON = _ToJSON_;
|
||||||
|
availableLabels = _availableLabels_;
|
||||||
|
|
||||||
$httpBackend
|
$httpBackend
|
||||||
.whenGET(/^\/api\/?$/)
|
.whenGET(/^\/api\/?$/)
|
||||||
@@ -88,7 +94,6 @@ describe('Controller: WorkflowAdd', () => {
|
|||||||
.whenGET(/\/static\/*/)
|
.whenGET(/\/static\/*/)
|
||||||
.respond(200, {});
|
.respond(200, {});
|
||||||
|
|
||||||
TemplatesService.getLabelOptions = jasmine.createSpy('getLabelOptions').and.returnValue(getLabelsDeferred.promise);
|
|
||||||
TemplatesService.createWorkflowJobTemplate = jasmine.createSpy('createWorkflowJobTemplate').and.returnValue(createWorkflowJobTemplateDeferred.promise);
|
TemplatesService.createWorkflowJobTemplate = jasmine.createSpy('createWorkflowJobTemplate').and.returnValue(createWorkflowJobTemplateDeferred.promise);
|
||||||
|
|
||||||
WorkflowAdd = $controller('WorkflowAdd', {
|
WorkflowAdd = $controller('WorkflowAdd', {
|
||||||
@@ -102,6 +107,7 @@ describe('Controller: WorkflowAdd', () => {
|
|||||||
CreateSelect2: CreateSelect2,
|
CreateSelect2: CreateSelect2,
|
||||||
Wait: Wait,
|
Wait: Wait,
|
||||||
ParseTypeChange: ParseTypeChange,
|
ParseTypeChange: ParseTypeChange,
|
||||||
|
availableLabels: availableLabels,
|
||||||
ToJSON
|
ToJSON
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
@@ -111,16 +117,13 @@ describe('Controller: WorkflowAdd', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get/set the label options and select2-ify the input', ()=>{
|
it('should get/set the label options and select2-ify the input', ()=>{
|
||||||
// Resolve TemplatesService.getLabelsForJobTemplate
|
|
||||||
getLabelsDeferred.resolve({
|
|
||||||
foo: "bar"
|
|
||||||
});
|
|
||||||
// We expect the digest cycle to fire off this call to /static/config.js so we go ahead and handle it
|
// We expect the digest cycle to fire off this call to /static/config.js so we go ahead and handle it
|
||||||
httpBackend.expectGET('/static/config.js').respond(200);
|
httpBackend.expectGET('/static/config.js').respond(200);
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
expect(scope.labelOptions).toEqual({
|
expect(scope.labelOptions).toEqual([{
|
||||||
foo: "bar"
|
label: "foo",
|
||||||
});
|
value: "1"
|
||||||
|
}]);
|
||||||
expect(CreateSelect2).toHaveBeenCalledWith({
|
expect(CreateSelect2).toHaveBeenCalledWith({
|
||||||
element:'#workflow_job_template_labels',
|
element:'#workflow_job_template_labels',
|
||||||
multiple: true,
|
multiple: true,
|
||||||
@@ -128,18 +131,6 @@ describe('Controller: WorkflowAdd', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call ProcessErrors when getLabelsForJobTemplate returns a rejected promise', ()=>{
|
|
||||||
// Reject TemplatesService.getLabelsForJobTemplate
|
|
||||||
getLabelsDeferred.reject({
|
|
||||||
data: "mockedData",
|
|
||||||
status: 400
|
|
||||||
});
|
|
||||||
// We expect the digest cycle to fire off this call to /static/config.js so we go ahead and handle it
|
|
||||||
httpBackend.expectGET('/static/config.js').respond(200);
|
|
||||||
scope.$digest();
|
|
||||||
expect(ProcessErrors).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('scope.formSave()', () => {
|
describe('scope.formSave()', () => {
|
||||||
|
|
||||||
it('should call TemplatesService.createWorkflowJobTemplate', ()=>{
|
it('should call TemplatesService.createWorkflowJobTemplate', ()=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user