-
Notifications
You must be signed in to change notification settings - Fork 0
/
remoteProjectManagerFormDirectiveTest.js
106 lines (90 loc) · 2.6 KB
/
remoteProjectManagerFormDirectiveTest.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
describe("directive: remoteProjectManagerForm", function () {
var $compile, $q, $scope, directive, element;
var initializeVariables = function () {
inject(function (_$q_, _$compile_) {
$q = _$q_;
$compile = _$compile_;
});
};
var initializeDirective = function (settings) {
inject(function (_$rootScope_) {
$scope = _$rootScope_.$new();
var attr = settings && settings.attr ? settings.attr : "management-settings='managementSettings' model='model'></remote-project-manager-form";
var body = settings && settings.body ? settings.body : "";
var managementType = settings && settings.managementType ? settings.managementType : "type";
var managementSettings = settings && settings.managementSettings ? settings.managementSettings : [
{
type: "text",
key: "url",
gloss: "URL",
visible: true
},{
type: "text",
key: "username",
gloss: "Username",
visible: false
}, {
type: "password",
key: "password",
gloss: "Password",
visible: false
}, {
type: "password",
key: "token",
gloss: "Token",
visible: false
}
];
var model = settings && settings.model ? settings.model : {
name: "",
type: "",
settings: {}
};
element = angular.element("<remote-project-manager-form " + attr + ">" + body + "</remote-project-manager-form>");
directive = $compile(element)($scope);
$scope.managementType = managementType;
$scope.managementSettings = managementSettings;
$scope.model = model;
$scope.$digest();
});
};
beforeEach(function () {
module("core");
module("app");
module("templates");
installPromiseMatchers();
initializeVariables();
});
describe("Is the directive", function () {
it("defined", function () {
initializeDirective();
expect(directive).toBeDefined();
});
it("defined with token auth", function () {
var settings = {
model: {
name: "",
type: "",
settings: {
token: "1234567890"
}
}
};
initializeDirective(settings);
expect(directive).toBeDefined();
});
it("defined with password auth", function () {
var settings = {
model: {
name: "",
type: "",
settings: {
password: "1234567890"
}
}
};
initializeDirective(settings);
expect(directive).toBeDefined();
});
});
});