This repository has been archived by the owner on May 7, 2020. It is now read-only.
/
configuration.binding.test.js
73 lines (72 loc) · 2.89 KB
/
configuration.binding.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
describe('module PaperUI.controllers.configuration.bindings', function() {
beforeEach(function() {
module('PaperUI');
});
describe('tests for BindingController', function() {
var bindingController, scope, mdDialog;
beforeEach(inject(function($injector, $rootScope, $controller, $mdDialog) {
scope = $rootScope.$new();
mdDialog = $mdDialog
$controller('BodyController', {
'$scope' : scope
});
bindingController = $controller('BindingController', {
'$scope' : scope
});
}));
it('should require BindingController', function() {
expect(bindingController).toBeDefined();
});
});
describe('tests for ConfigureBindingDialogController', function() {
var configureBindingDialogController, scope, bindingService;
var restConfig;
beforeEach(inject(function($injector, $rootScope, $controller) {
scope = $rootScope.$new();
var bindingRepository = $injector.get('bindingRepository');
restConfig = $injector.get('restConfig');
$rootScope.data.bindings = [ {
id : 'B'
} ];
configureBindingDialogController = $controller('ConfigureBindingDialogController', {
'$scope' : scope,
'binding' : {
'id' : 'B',
'configDescriptionURI' : 'CDURI'
},
'bindingRepository' : bindingRepository
});
$httpBackend = $injector.get('$httpBackend');
$httpBackend.when('GET', restConfig.restPath + "/config-descriptions/CDURI").respond({
parameters : [ {
type : 'input',
name : 'PNAME'
} ]
});
$httpBackend.when('GET', restConfig.restPath + "/bindings/B/config").respond({
PNAME : '1'
});
$httpBackend.flush();
bindingService = $injector.get('bindingService');
}));
it('should require ConfigureBindingDialogController', function() {
expect(configureBindingDialogController).toBeDefined();
});
it('should get binding parameters', function() {
expect(scope.parameters.length).toEqual(1);
});
it('should get binding configuration', function() {
expect(scope.configuration.PNAME).toEqual(1);
});
it('should add binding parameter', function() {
scope.configArray = [];
scope.addParameter();
expect(scope.configArray.length).toEqual(1);
});
it('should save binding configuration', function() {
spyOn(bindingService, 'updateConfig');
scope.save();
expect(bindingService.updateConfig).toHaveBeenCalled();
});
});
});