This repository was archived by the owner on Sep 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathuiLayoutCtrl.spec.js
More file actions
121 lines (85 loc) · 3.35 KB
/
uiLayoutCtrl.spec.js
File metadata and controls
121 lines (85 loc) · 3.35 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
'use strict';
describe('Controller: uiLayoutCtrl', function () {
var scope, $controller;
beforeEach(function () {
module('ui.layout');
inject(function ($rootScope, _$controller_) {
scope = $rootScope.$new();
$controller = _$controller_;
});
});
describe('ctrl functions', function () {
it('isLayoutElement', function () {
var uic = $controller('uiLayoutCtrl', {
$scope: scope,
$attrs: {},
$element: angular.element('<div></div>')
});
var attrContainer = document.createElement('div');
attrContainer.setAttribute('ui-layout-container', '');
var attrSplitbar = document.createElement('div');
attrSplitbar.setAttribute('ui-splitbar', '');
var tagContainer = document.createElement('ui-layout-container');
var notUiEl = document.createElement('div');
expect(uic.isLayoutElement(attrContainer)).toEqual(true);
expect(uic.isLayoutElement(attrSplitbar)).toEqual(true);
expect(uic.isLayoutElement(tagContainer)).toEqual(true);
expect(uic.isLayoutElement(notUiEl)).toEqual(false);
});
describe('getMousePosition', function(){
var controller;
beforeEach(function(){
controller = $controller('uiLayoutCtrl', {
$scope: scope,
$attrs: {},
$element: angular.element('<div></div>')});
});
it('should handle standard mouse event', function(){
var mockMouseEvent = {};
mockMouseEvent[controller.sizeProperties.mouseProperty] = 0;
var result = controller.getMousePosition(mockMouseEvent);
expect(result).toEqual(0);
});
it('should handle jQuery mouse event', function(){
var mockMouseEvent = {
originalEvent: {}
};
mockMouseEvent.originalEvent[controller.sizeProperties.mouseProperty] = 0;
var result = controller.getMousePosition(mockMouseEvent);
expect(result).toEqual(0);
});
it('should handle standard touch event', function(){
var mockMouseEvent = {
targetTouches: []
};
mockMouseEvent.targetTouches[0] = {};
mockMouseEvent.targetTouches[0][controller.sizeProperties.mouseProperty] = 0;
var result = controller.getMousePosition(mockMouseEvent);
expect(result).toEqual(0);
});
it('should handle unrecognised standard event', function(){
var mockMouseEvent = {};
var result = controller.getMousePosition(mockMouseEvent);
expect(result).toEqual(null);
});
it('should handle jQuery touch event', function(){
var mockMouseEvent = {
originalEvent: {
targetTouches: []
}
};
mockMouseEvent.originalEvent.targetTouches[0] = {};
mockMouseEvent.originalEvent.targetTouches[0][controller.sizeProperties.mouseProperty] = 0;
var result = controller.getMousePosition(mockMouseEvent);
expect(result).toEqual(0);
});
it('should handle unrecognised jQuery event', function(){
var mockMouseEvent = {
originalEvent: {}
};
var result = controller.getMousePosition(mockMouseEvent);
expect(result).toEqual(null);
});
});
});
});