@eclipse-scout/karma-jasmine-scout 22.0.39 → 23.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/index.js +1 -5
- package/src/cloneMatchers.js +0 -98
- package/src/jasmineScoutHelpers.js +0 -157
- package/src/jqueryExtensions.js +0 -240
- package/src/scoutMatchers.js +0 -178
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-scout/karma-jasmine-scout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "23.1.0-beta.4",
|
|
4
4
|
"description": "Scout plugin for Jasmine in Karma",
|
|
5
5
|
"author": "BSI Business Systems Integration AG",
|
|
6
6
|
"homepage": "https://www.eclipse.org/scout",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
},
|
|
11
11
|
"license": "EPL-1.0",
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
14
|
-
"npm": ">=
|
|
15
|
-
"pnpm": ">=
|
|
13
|
+
"node": ">=18.12.1",
|
|
14
|
+
"npm": ">=9.1.1",
|
|
15
|
+
"pnpm": ">=7.16.0"
|
|
16
16
|
},
|
|
17
17
|
"main": "src/index.js",
|
|
18
18
|
"files": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@eclipse-scout/releng": "^22.0.0",
|
|
23
|
-
"jasmine-core": "
|
|
23
|
+
"jasmine-core": "4.5.0",
|
|
24
24
|
"jasmine-ajax": "4.0.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
package/src/index.js
CHANGED
|
@@ -30,11 +30,7 @@ let initJasmine_scout = files => {
|
|
|
30
30
|
files.splice(insertPos, 0,
|
|
31
31
|
createPattern(require.resolve('sourcemapped-stacktrace')),
|
|
32
32
|
createPattern(path.join(__dirname, 'stackTraceMapper.js')),
|
|
33
|
-
createPattern(path.join(__dirname, '
|
|
34
|
-
createPattern(path.join(__dirname, 'cloneMatchers.js')),
|
|
35
|
-
createPattern(path.join(__dirname, 'jqueryExtensions.js')),
|
|
36
|
-
createPattern(path.join(__dirname, 'JasmineScout.css')),
|
|
37
|
-
createPattern(path.join(__dirname, 'jasmineScoutHelpers.js')));
|
|
33
|
+
createPattern(path.join(__dirname, 'JasmineScout.css')));
|
|
38
34
|
};
|
|
39
35
|
|
|
40
36
|
initJasmine_scout.$inject = ['config.files'];
|
package/src/cloneMatchers.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2010-2019 BSI Business Systems Integration AG.
|
|
3
|
-
* All rights reserved. This program and the accompanying materials
|
|
4
|
-
* are made available under the terms of the Eclipse Public License v1.0
|
|
5
|
-
* which accompanies this distribution, and is available at
|
|
6
|
-
* http://www.eclipse.org/legal/epl-v10.html
|
|
7
|
-
*
|
|
8
|
-
* Contributors:
|
|
9
|
-
* BSI Business Systems Integration AG - initial API and implementation
|
|
10
|
-
*/
|
|
11
|
-
const jasmineScoutCloneMatchers = {
|
|
12
|
-
definedProperty: (util, customEqualityTesters) => ({
|
|
13
|
-
compare: (original, clone, property) => {
|
|
14
|
-
let result = {
|
|
15
|
-
pass: clone[property] !== undefined
|
|
16
|
-
};
|
|
17
|
-
if (!result.pass) {
|
|
18
|
-
result.message = clone.objectType + ' does not have the property ' + property + ' [original:' + original[property] + ', clone:' + clone[property] + ']!';
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
}),
|
|
24
|
-
sameProperty: (util, customEqualityTesters) => ({
|
|
25
|
-
compare: (original, clone, property) => {
|
|
26
|
-
let result = {
|
|
27
|
-
pass: original[property] === clone[property]
|
|
28
|
-
};
|
|
29
|
-
if (!result.pass) {
|
|
30
|
-
result.message = 'property \'' + property + '\' is not the same [original: \'' + original[property] + '\', clone: \'' + clone[property] + '\'].';
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}),
|
|
36
|
-
widgetCloneProperty: (util, customEqualityTesters) => ({
|
|
37
|
-
compare: (original, clone, property) => {
|
|
38
|
-
let compareWidget = (originalWidget, clonedWidget, propertyName) => {
|
|
39
|
-
if (originalWidget === clonedWidget) {
|
|
40
|
-
return {
|
|
41
|
-
pass: false,
|
|
42
|
-
message: 'widgetProperty \'' + property + '\' is same on [original: \'' + original[property] + '\', clone: \'' + clone[property] + '\']. It should be a deep copy.'
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (originalWidget.objectType !== clonedWidget.objectType) {
|
|
46
|
-
return {
|
|
47
|
-
pass: false,
|
|
48
|
-
message: 'widgetProperty \'' + property + '\' has not same object type of clone and orignal. [original.objectType: \'' + originalWidget.objectType + '\', clonedWidget.objectType: \'' + clonedWidget.objectType + '\'].'
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
if (clonedWidget.parent !== clone) {
|
|
52
|
-
return {
|
|
53
|
-
pass: false,
|
|
54
|
-
message: 'widgetProperty \'' + property + '\' has a wrong parent in clone (widget parent and clone should be same). [clone: \'' + clone + '\', widget.parent: \'' + clonedWidget.parent + '\'].'
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
if (originalWidget !== clonedWidget.cloneOf) {
|
|
58
|
-
return {
|
|
59
|
-
pass: false,
|
|
60
|
-
message: 'widgetProperty \'' + property + '\' cloneOf of clone is not set correctly. [original: \'' + originalWidget + '\', clone.cloneOf: \'' + clonedWidget.cloneOf + '\'].'
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
pass: true
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
};
|
|
68
|
-
if (original[property] === clone[property]) {
|
|
69
|
-
return {
|
|
70
|
-
pass: false,
|
|
71
|
-
message: 'widgetProperty \'' + property + '\' is same on [original: \'' + original[property] + '\', clone: \'' + clone[property] + '\']. It should be a deep copy.'
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
if (Array.isArray(original[property])) {
|
|
75
|
-
if (!Array.isArray(clone[property])) {
|
|
76
|
-
return {
|
|
77
|
-
pass: false,
|
|
78
|
-
message: 'widgetProperty \'' + property + '\' is not an array [original: \'' + original[property] + '\', clone: \'' + clone[property] + '\']. It should be a deep copy.'
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
for (let i = 0; i < original[property].length; i++) {
|
|
82
|
-
let result = compareWidget(original[property][i], clone[property][i], property);
|
|
83
|
-
if (!result.pass) {
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
pass: true
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
beforeEach(() => {
|
|
97
|
-
jasmine.addMatchers(jasmineScoutCloneMatchers);
|
|
98
|
-
});
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2010-2019 BSI Business Systems Integration AG.
|
|
3
|
-
* All rights reserved. This program and the accompanying materials
|
|
4
|
-
* are made available under the terms of the Eclipse Public License v1.0
|
|
5
|
-
* which accompanies this distribution, and is available at
|
|
6
|
-
* http://www.eclipse.org/legal/epl-v10.html
|
|
7
|
-
*
|
|
8
|
-
* Contributors:
|
|
9
|
-
* BSI Business Systems Integration AG - initial API and implementation
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
window.mostRecentJsonRequest = () => {
|
|
13
|
-
let req = jasmine.Ajax.requests.mostRecent();
|
|
14
|
-
if (req) {
|
|
15
|
-
return $.parseJSON(req.params);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
window.sandboxDesktop = () => {
|
|
20
|
-
let $sandbox = window.sandbox();
|
|
21
|
-
$sandbox.addClass('scout desktop');
|
|
22
|
-
return $sandbox;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Sends the queued requests and simulates a response as well.
|
|
27
|
-
* @param response if not set an empty success response will be generated
|
|
28
|
-
*/
|
|
29
|
-
window.sendQueuedAjaxCalls = (response, time) => {
|
|
30
|
-
time = time || 0;
|
|
31
|
-
jasmine.clock().tick(time);
|
|
32
|
-
|
|
33
|
-
receiveResponseForAjaxCall('', response);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
window.receiveResponseForAjaxCall = (request, response) => {
|
|
37
|
-
if (!response) {
|
|
38
|
-
response = {
|
|
39
|
-
status: 200,
|
|
40
|
-
responseText: '{"events":[]}'
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
if (!request) {
|
|
44
|
-
request = jasmine.Ajax.requests.mostRecent();
|
|
45
|
-
}
|
|
46
|
-
if (request && request.onload) {
|
|
47
|
-
request.respondWith(response);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Uninstalls 'beforeunload' and 'unload' events from window that were previously installed by session.start()
|
|
53
|
-
*/
|
|
54
|
-
window.uninstallUnloadHandlers = session => {
|
|
55
|
-
$(window)
|
|
56
|
-
.off('beforeunload.' + session.uiSessionId)
|
|
57
|
-
.off('unload.' + session.uiSessionId);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
window.createPropertyChangeEvent = (model, properties) => ({
|
|
61
|
-
target: model.id,
|
|
62
|
-
properties: properties,
|
|
63
|
-
type: 'property'
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Returns a new object instance having two properties id, objectType from the given widgetModel.
|
|
68
|
-
* this function is required because the model object passed to the scout.create() function is modified
|
|
69
|
-
* --> model.objectType is changed to whatever string is passed as parameter objectType
|
|
70
|
-
*
|
|
71
|
-
* @param widgetModel
|
|
72
|
-
*/
|
|
73
|
-
window.createAdapterModel = widgetModel => ({
|
|
74
|
-
id: widgetModel.id,
|
|
75
|
-
objectType: widgetModel.objectType,
|
|
76
|
-
session: widgetModel.session
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
window.stripCommentsFromJson = input => {
|
|
80
|
-
if (!input || typeof input !== 'string') {
|
|
81
|
-
return input;
|
|
82
|
-
}
|
|
83
|
-
let result = '';
|
|
84
|
-
let whitespaceBuffer = '';
|
|
85
|
-
for (let i = 0; i < input.length; i++) {
|
|
86
|
-
let previousCharacter = input.charAt(i - 1);
|
|
87
|
-
let currentCharacter = input.charAt(i);
|
|
88
|
-
let nextCharacter = input.charAt(i + 1);
|
|
89
|
-
|
|
90
|
-
// Add whitespace to a buffer (because me might want to ignore it at the end of a line)
|
|
91
|
-
if (currentCharacter === ' ' || currentCharacter === '\t') {
|
|
92
|
-
whitespaceBuffer += currentCharacter;
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
// Handle end of line
|
|
96
|
-
if (currentCharacter === '\r') {
|
|
97
|
-
if (nextCharacter === '\n') {
|
|
98
|
-
// Handle \r\n as \n
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
// Handle \r as \n
|
|
102
|
-
currentCharacter = '\n';
|
|
103
|
-
}
|
|
104
|
-
if (currentCharacter === '\n') {
|
|
105
|
-
whitespaceBuffer = ''; // discard whitespace
|
|
106
|
-
// Add line break (but not at the begin and not after another line break)
|
|
107
|
-
if (result.charAt(result.length - 1) !== '\n') {
|
|
108
|
-
result += currentCharacter;
|
|
109
|
-
}
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Handle strings
|
|
114
|
-
if (currentCharacter === '"' && previousCharacter !== '\\') {
|
|
115
|
-
// Flush whitespace to result
|
|
116
|
-
result += whitespaceBuffer;
|
|
117
|
-
whitespaceBuffer = '';
|
|
118
|
-
result += currentCharacter;
|
|
119
|
-
for (i++; i < input.length; i++) {
|
|
120
|
-
previousCharacter = input.charAt(i - 1);
|
|
121
|
-
currentCharacter = input.charAt(i);
|
|
122
|
-
nextCharacter = input.charAt(i + 1);
|
|
123
|
-
result += currentCharacter;
|
|
124
|
-
if (currentCharacter === '"' && previousCharacter !== '\\') {
|
|
125
|
-
break; // end of string
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
} else if (currentCharacter === '/' && nextCharacter === '*') {
|
|
129
|
-
// Handle multi-line comments
|
|
130
|
-
for (i++; i < input.length; i++) {
|
|
131
|
-
previousCharacter = input.charAt(i - 1);
|
|
132
|
-
currentCharacter = input.charAt(i);
|
|
133
|
-
nextCharacter = input.charAt(i + 1);
|
|
134
|
-
if (currentCharacter === '/' && previousCharacter === '*') {
|
|
135
|
-
break; // end of multi-line comment
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
} else if (currentCharacter === '/' && nextCharacter === '/') {
|
|
139
|
-
// Handle single-line comment
|
|
140
|
-
for (i++; i < input.length; i++) {
|
|
141
|
-
previousCharacter = input.charAt(i - 1);
|
|
142
|
-
currentCharacter = input.charAt(i);
|
|
143
|
-
nextCharacter = input.charAt(i + 1);
|
|
144
|
-
if (nextCharacter === '\n' || nextCharacter === '\r') {
|
|
145
|
-
break; // end of single-line comment
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
// regular character
|
|
150
|
-
// Flush whitespace to result
|
|
151
|
-
result += whitespaceBuffer;
|
|
152
|
-
whitespaceBuffer = '';
|
|
153
|
-
result += currentCharacter;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return result;
|
|
157
|
-
};
|
package/src/jqueryExtensions.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2010-2021 BSI Business Systems Integration AG.
|
|
3
|
-
* All rights reserved. This program and the accompanying materials
|
|
4
|
-
* are made available under the terms of the Eclipse Public License v1.0
|
|
5
|
-
* which accompanies this distribution, and is available at
|
|
6
|
-
* http://www.eclipse.org/legal/epl-v10.html
|
|
7
|
-
*
|
|
8
|
-
* Contributors:
|
|
9
|
-
* BSI Business Systems Integration AG - initial API and implementation
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/* eslint-disable new-cap */
|
|
13
|
-
|
|
14
|
-
// JQuery extensions for testing purpose
|
|
15
|
-
|
|
16
|
-
$.fn.triggerBlur = function() {
|
|
17
|
-
let event = jQuery.Event('blur', {
|
|
18
|
-
originalEvent: jQuery.Event('dummy') // create dummy object
|
|
19
|
-
});
|
|
20
|
-
this.trigger(event);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
$.fn.triggerRightClick = function() {
|
|
24
|
-
this.trigger(jQuery.Event('mousedown', {which: 3}));
|
|
25
|
-
this.trigger(jQuery.Event('mouseup', {which: 3}));
|
|
26
|
-
return this;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
$.fn.triggerKeyUp = function(key, modifier) {
|
|
30
|
-
let event = jQuery.Event('keyup', {
|
|
31
|
-
originalEvent: jQuery.Event('dummy'), // create dummy object
|
|
32
|
-
which: key
|
|
33
|
-
});
|
|
34
|
-
extendEventWithModifier(event, modifier);
|
|
35
|
-
this.trigger(event);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
$.fn.triggerKeyDown = function(key, modifier) {
|
|
39
|
-
let event = jQuery.Event('keydown', {
|
|
40
|
-
originalEvent: jQuery.Event('dummy'), // create dummy object
|
|
41
|
-
which: key
|
|
42
|
-
});
|
|
43
|
-
extendEventWithModifier(event, modifier);
|
|
44
|
-
this.trigger(event);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
function extendEventWithModifier(event, modifier) {
|
|
48
|
-
event.altKey = modifier === 'alt';
|
|
49
|
-
event.ctrlKey = modifier === 'ctrl';
|
|
50
|
-
event.shiftKey = modifier === 'shift';
|
|
51
|
-
event.metaKey = modifier === 'meta';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
$.fn.triggerMouseEnter = function(opts) {
|
|
55
|
-
return this.triggerMouseAction('mouseenter', opts);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
$.fn.triggerMouseLeave = function(opts) {
|
|
59
|
-
return this.triggerMouseAction('mouseleave', opts);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
$.fn.triggerMouseDown = function(opts) {
|
|
63
|
-
return this.triggerMouseAction('mousedown', opts);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Does not use jQuery to create the event to make sure capture phase listeners are notified as well.
|
|
68
|
-
*/
|
|
69
|
-
$.fn.triggerMouseDownCapture = function(opts) {
|
|
70
|
-
let event;
|
|
71
|
-
try {
|
|
72
|
-
event = new MouseEvent('mousedown', {
|
|
73
|
-
'view': window,
|
|
74
|
-
'bubbles': true,
|
|
75
|
-
'cancelable': true
|
|
76
|
-
});
|
|
77
|
-
} catch (e) {
|
|
78
|
-
// Phantom JS only supports the old, deprecated API
|
|
79
|
-
event = document.createEvent('MouseEvent');
|
|
80
|
-
event.initEvent('mousedown', true, true);
|
|
81
|
-
}
|
|
82
|
-
this[0].dispatchEvent(event);
|
|
83
|
-
return this;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
$.fn.triggerKeyDownCapture = function(which, modifier) {
|
|
87
|
-
return this.triggerKeyCapture('keydown', which, modifier);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
$.fn.triggerKeyUpCapture = function(which, modifier) {
|
|
91
|
-
return this.triggerKeyCapture('keyup', which, modifier);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Triggers key down and key up events.
|
|
96
|
-
*/
|
|
97
|
-
$.fn.triggerKeyInputCapture = function(which, modifier) {
|
|
98
|
-
this.triggerKeyCapture('keydown', which, modifier);
|
|
99
|
-
this.triggerKeyCapture('keyup', which, modifier);
|
|
100
|
-
return this;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
$.fn.triggerKeyCapture = function(eventType, which, modifier) {
|
|
104
|
-
// Due to a Chrome bug, "new KeyboardEvent" cannot be used,
|
|
105
|
-
// as it doesn't set "which". We have to use this less specific
|
|
106
|
-
// constructor.
|
|
107
|
-
let eventObj;
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
eventObj = new Event(eventType, {
|
|
111
|
-
'bubbles': true,
|
|
112
|
-
'cancelable': true
|
|
113
|
-
});
|
|
114
|
-
} catch (e) {
|
|
115
|
-
// Workaround for PhantomJS
|
|
116
|
-
eventObj = document.createEvent('CustomEvent');
|
|
117
|
-
eventObj.initEvent(eventType, true, true);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
eventObj.keyCode = which;
|
|
121
|
-
eventObj.which = which;
|
|
122
|
-
extendEventWithModifier(eventObj, modifier);
|
|
123
|
-
|
|
124
|
-
this[0].dispatchEvent(eventObj);
|
|
125
|
-
return this;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
$.fn.triggerMouseUp = function(opts) {
|
|
129
|
-
return this.triggerMouseAction('mouseup', opts);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
$.fn.triggerMouseMove = function(position) {
|
|
133
|
-
return this.triggerWithPosition('mousemove', {
|
|
134
|
-
position: position
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
$.fn.triggerMouseAction = function(eventType, opts) {
|
|
139
|
-
let event;
|
|
140
|
-
opts = opts || {};
|
|
141
|
-
|
|
142
|
-
if (!opts.position) {
|
|
143
|
-
opts.position = this.offset();
|
|
144
|
-
}
|
|
145
|
-
if (!opts.clicks) {
|
|
146
|
-
opts.clicks = 1;
|
|
147
|
-
}
|
|
148
|
-
if (!opts.which) {
|
|
149
|
-
opts.which = 1;
|
|
150
|
-
}
|
|
151
|
-
event = jQuery.Event(eventType, {
|
|
152
|
-
which: opts.which,
|
|
153
|
-
originalEvent: jQuery.Event(eventType, {
|
|
154
|
-
detail: opts.clicks
|
|
155
|
-
}),
|
|
156
|
-
pageX: opts.position.left,
|
|
157
|
-
pageY: opts.position.top
|
|
158
|
-
});
|
|
159
|
-
if (opts.modifier) {
|
|
160
|
-
extendEventWithModifier(event, opts.modifier);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
this.trigger(event);
|
|
164
|
-
return this;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
$.fn.triggerWithPosition = function(event, position) {
|
|
168
|
-
if (!position) {
|
|
169
|
-
position = this.offset();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
this.trigger({
|
|
173
|
-
type: event,
|
|
174
|
-
pageX: position.left,
|
|
175
|
-
pageY: position.right
|
|
176
|
-
});
|
|
177
|
-
return this;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
$.fn.triggerContextMenu = function() {
|
|
181
|
-
let opts = {
|
|
182
|
-
position: this.offset(),
|
|
183
|
-
which: 3
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
this.triggerMouseDown(opts);
|
|
187
|
-
this.triggerMouseUp(opts);
|
|
188
|
-
this.trigger(jQuery.Event('contextmenu', {
|
|
189
|
-
pageX: opts.position.left,
|
|
190
|
-
pageY: opts.position.top
|
|
191
|
-
}));
|
|
192
|
-
return this;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Triggers mouse down, mouse up and click events. <br>
|
|
197
|
-
* Also sets the detail property of the originalEvent which contains the numbers of clicks.
|
|
198
|
-
* @param opts options object passed to triggerMouse* functions
|
|
199
|
-
*/
|
|
200
|
-
$.fn.triggerClick = function(opts) {
|
|
201
|
-
opts = opts || {};
|
|
202
|
-
|
|
203
|
-
if (!opts.click) {
|
|
204
|
-
opts.click = 1;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
this.triggerMouseDown(opts);
|
|
208
|
-
this.triggerMouseUp(opts);
|
|
209
|
-
this.triggerMouseAction('click', opts);
|
|
210
|
-
|
|
211
|
-
return this;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
$.fn.triggerDoubleClick = function() {
|
|
215
|
-
this.triggerClick();
|
|
216
|
-
this.triggerClick({click: 2});
|
|
217
|
-
this.trigger(jQuery.Event('dblclick', {
|
|
218
|
-
originalEvent: jQuery.Event('dummy', {
|
|
219
|
-
detail: 2
|
|
220
|
-
})
|
|
221
|
-
}));
|
|
222
|
-
return this;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
$.fn.triggerImageLoadCapture = function(opts) {
|
|
226
|
-
let event;
|
|
227
|
-
try {
|
|
228
|
-
event = new Event('load', {
|
|
229
|
-
'view': window,
|
|
230
|
-
'bubbles': true,
|
|
231
|
-
'cancelable': true
|
|
232
|
-
});
|
|
233
|
-
} catch (e) {
|
|
234
|
-
// Phantom JS only supports the old, deprecated API
|
|
235
|
-
event = document.createEvent('Event');
|
|
236
|
-
event.initEvent('load', true, true);
|
|
237
|
-
}
|
|
238
|
-
this[0].dispatchEvent(event);
|
|
239
|
-
return this;
|
|
240
|
-
};
|
package/src/scoutMatchers.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2010-2019 BSI Business Systems Integration AG.
|
|
3
|
-
* All rights reserved. This program and the accompanying materials
|
|
4
|
-
* are made available under the terms of the Eclipse Public License v1.0
|
|
5
|
-
* which accompanies this distribution, and is available at
|
|
6
|
-
* http://www.eclipse.org/legal/epl-v10.html
|
|
7
|
-
*
|
|
8
|
-
* Contributors:
|
|
9
|
-
* BSI Business Systems Integration AG - initial API and implementation
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const jasmineScoutMatchers = {
|
|
13
|
-
/**
|
|
14
|
-
* Checks if given request contains expected events, order does not matter.
|
|
15
|
-
* @actual json request, may be obtained by mostRecentJsonRequest
|
|
16
|
-
*/
|
|
17
|
-
toContainEvents: (util, customEqualityTesters) => ({
|
|
18
|
-
compare: (actual, expected) => {
|
|
19
|
-
if (expected === undefined) {
|
|
20
|
-
expected = [];
|
|
21
|
-
}
|
|
22
|
-
if (!Array.isArray(expected)) {
|
|
23
|
-
expected = [expected];
|
|
24
|
-
}
|
|
25
|
-
let result = {},
|
|
26
|
-
i;
|
|
27
|
-
|
|
28
|
-
let actualEvents = [];
|
|
29
|
-
if (actual) {
|
|
30
|
-
for (i = 0; i < actual.events.length; i++) {
|
|
31
|
-
actualEvents.push(actual.events[i]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
result.pass = true;
|
|
36
|
-
for (i = 0; i < expected.length; i++) {
|
|
37
|
-
// Prototype may be Event. If that's the case we need to convert, otherwise equals will fail
|
|
38
|
-
if (Object.getPrototypeOf(expected[i]) !== Object.prototype) {
|
|
39
|
-
expected[i] = $.parseJSON(JSON.stringify(expected[i]));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
result.pass = result.pass && util.contains(actualEvents, expected[i], customEqualityTesters);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!result.pass) {
|
|
46
|
-
result.message = 'Expected actual events ' + actualEvents + ' to be equal to ' + expected;
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
}),
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Checks if given request contains all the expected events in the given order
|
|
54
|
-
* @actual json request, may be obtained by mostRecentJsonRequest
|
|
55
|
-
*/
|
|
56
|
-
toContainEventsExactly: (util, customEqualityTesters) => ({
|
|
57
|
-
compare: (actual, expected) => {
|
|
58
|
-
if (expected === undefined) {
|
|
59
|
-
expected = [];
|
|
60
|
-
}
|
|
61
|
-
if (!Array.isArray(expected)) {
|
|
62
|
-
expected = [expected];
|
|
63
|
-
}
|
|
64
|
-
let result = {},
|
|
65
|
-
i;
|
|
66
|
-
|
|
67
|
-
let actualEvents = [];
|
|
68
|
-
if (actual) {
|
|
69
|
-
for (i = 0; i < actual.events.length; i++) {
|
|
70
|
-
actualEvents.push(actual.events[i]);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
result.pass = true;
|
|
75
|
-
for (i = 0; i < expected.length; i++) {
|
|
76
|
-
// Prototype may be Event. If that's the case we need to convert, otherwise equals will fail
|
|
77
|
-
if (Object.getPrototypeOf(expected[i]) !== Object.prototype) {
|
|
78
|
-
expected[i] = $.parseJSON(JSON.stringify(expected[i]));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
result.pass = util.equals(actualEvents, expected, customEqualityTesters);
|
|
83
|
-
|
|
84
|
-
if (!result.pass) {
|
|
85
|
-
result.message = 'Expected actual events ' + actualEvents + ' to be equal to ' + expected;
|
|
86
|
-
}
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
}),
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Checks if given request contains events with the expected event types in the given order
|
|
93
|
-
* @actual json request, may be obtained by mostRecentJsonRequest
|
|
94
|
-
*/
|
|
95
|
-
toContainEventTypesExactly: (util, customEqualityTesters) => ({
|
|
96
|
-
compare: (actual, expected) => {
|
|
97
|
-
if (expected === undefined) {
|
|
98
|
-
expected = [];
|
|
99
|
-
}
|
|
100
|
-
if (!Array.isArray(expected)) {
|
|
101
|
-
expected = [expected];
|
|
102
|
-
}
|
|
103
|
-
let result = {};
|
|
104
|
-
|
|
105
|
-
let actualEventTypes = [];
|
|
106
|
-
if (actual) {
|
|
107
|
-
for (let i = 0; i < actual.events.length; i++) {
|
|
108
|
-
actualEventTypes.push(actual.events[i].type);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
result.pass = util.equals(actualEventTypes, expected, customEqualityTesters);
|
|
113
|
-
|
|
114
|
-
if (!result.pass) {
|
|
115
|
-
result.message = 'Expected actual event types ' + actualEventTypes + ' to be equal to ' + expected;
|
|
116
|
-
}
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
}),
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Checks if all given jQuery objects (array of jQuery objects) have a specific class (list).
|
|
123
|
-
*/
|
|
124
|
-
allToHaveClass: (util, customEqualityTesters) => ({
|
|
125
|
-
compare: (actual, expected) => {
|
|
126
|
-
if (expected === undefined) {
|
|
127
|
-
expected = [];
|
|
128
|
-
}
|
|
129
|
-
if (!Array.isArray(expected)) {
|
|
130
|
-
expected = [expected];
|
|
131
|
-
}
|
|
132
|
-
if (!Array.isArray(actual)) {
|
|
133
|
-
actual = [actual];
|
|
134
|
-
}
|
|
135
|
-
let result = {
|
|
136
|
-
pass: actual.every($elem => {
|
|
137
|
-
return $elem.hasClass(expected);
|
|
138
|
-
})
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
if (!result.pass) {
|
|
142
|
-
result.message = 'Expected ' + actual + ' all to have ' + expected + ' as classes.';
|
|
143
|
-
}
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
|
-
}),
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Checks if any given jQuery object (array of jQuery objects) has a specific class (list).
|
|
150
|
-
*/
|
|
151
|
-
anyToHaveClass: (util, customEqualityTesters) => ({
|
|
152
|
-
compare: (actual, expected) => {
|
|
153
|
-
if (expected === undefined) {
|
|
154
|
-
expected = [];
|
|
155
|
-
}
|
|
156
|
-
if (!Array.isArray(expected)) {
|
|
157
|
-
expected = [expected];
|
|
158
|
-
}
|
|
159
|
-
if (!Array.isArray(actual)) {
|
|
160
|
-
actual = [actual];
|
|
161
|
-
}
|
|
162
|
-
let result = {
|
|
163
|
-
pass: actual.some($elem => {
|
|
164
|
-
return $elem.hasClass(expected);
|
|
165
|
-
})
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
if (!result.pass) {
|
|
169
|
-
result.message = 'Expected any ' + actual + ' to have ' + expected + ' as classes.';
|
|
170
|
-
}
|
|
171
|
-
return result;
|
|
172
|
-
}
|
|
173
|
-
})
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
beforeEach(() => {
|
|
177
|
-
jasmine.addMatchers(jasmineScoutMatchers);
|
|
178
|
-
});
|