Skip to content

Commit e46f461

Browse files
committed
3.4.4
1 parent 2ba539b commit e46f461

35 files changed

+11830
-0
lines changed

dist/amd/browser/actions.js

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/*[email protected]#browser/actions*/
2+
define(function (require, exports, module) {
3+
var $ = require('./jquery');
4+
var FuncUnit = require('./core');
5+
var syn = window.syn = require('syn');
6+
var clicks = [
7+
'click',
8+
'dblclick',
9+
'rightClick'
10+
], makeClick = function (name) {
11+
FuncUnit.prototype[name] = function (options, success) {
12+
this._addExists();
13+
if (typeof options == 'function') {
14+
success = options;
15+
options = {};
16+
}
17+
var selector = this.selector;
18+
FuncUnit.add({
19+
method: function (success, error) {
20+
options = options || {};
21+
syn('_' + name, this.bind[0], options, success);
22+
},
23+
success: success,
24+
error: 'Could not ' + name + ' \'' + this.selector + '\'',
25+
bind: this,
26+
type: 'action'
27+
});
28+
return this;
29+
};
30+
};
31+
for (var i = 0; i < clicks.length; i++) {
32+
makeClick(clicks[i]);
33+
}
34+
$.extend(FuncUnit.prototype, {
35+
_addExists: function () {
36+
this.exists(false);
37+
},
38+
type: function (text, success) {
39+
this._addExists();
40+
this.click();
41+
var selector = this.selector;
42+
if (text === '') {
43+
text = '[ctrl]a[ctrl-up]\b';
44+
}
45+
FuncUnit.add({
46+
method: function (success, error) {
47+
syn('_type', this.bind[0], text, success);
48+
},
49+
success: success,
50+
error: 'Could not type ' + text + ' into ' + this.selector,
51+
bind: this,
52+
type: 'action'
53+
});
54+
return this;
55+
},
56+
sendKeys: function (keys, success) {
57+
this._addExists();
58+
var selector = this.selector;
59+
if (keys === '') {
60+
keys = '[ctrl]a[ctrl-up]\b';
61+
}
62+
FuncUnit.add({
63+
method: function (success, error) {
64+
syn('_type', this.bind[0], keys, success);
65+
},
66+
success: success,
67+
error: 'Could not send the keys ' + keys + ' into ' + this.selector,
68+
bind: this,
69+
type: 'action'
70+
});
71+
return this;
72+
},
73+
trigger: function (evName, success) {
74+
this._addExists();
75+
FuncUnit.add({
76+
method: function (success, error) {
77+
if (!FuncUnit.win.jQuery) {
78+
throw 'Can not trigger custom event, no jQuery found on target page.';
79+
}
80+
FuncUnit.win.jQuery(this.bind.selector).trigger(evName);
81+
success();
82+
},
83+
success: success,
84+
error: 'Could not trigger ' + evName,
85+
bind: this,
86+
type: 'action'
87+
});
88+
return this;
89+
},
90+
drag: function (options, success) {
91+
this._addExists();
92+
if (typeof options == 'string') {
93+
options = { to: options };
94+
}
95+
options.from = this.selector;
96+
var selector = this.selector;
97+
FuncUnit.add({
98+
method: function (success, error) {
99+
syn('_drag', this.bind[0], options, success);
100+
},
101+
success: success,
102+
error: 'Could not drag ' + this.selector,
103+
bind: this,
104+
type: 'action'
105+
});
106+
return this;
107+
},
108+
move: function (options, success) {
109+
this._addExists();
110+
if (typeof options == 'string') {
111+
options = { to: options };
112+
}
113+
options.from = this.selector;
114+
var selector = this.selector;
115+
FuncUnit.add({
116+
method: function (success, error) {
117+
syn('_move', this.bind[0], options, success);
118+
},
119+
success: success,
120+
error: 'Could not move ' + this.selector,
121+
bind: this,
122+
type: 'action'
123+
});
124+
return this;
125+
},
126+
scroll: function (direction, amount, success) {
127+
this._addExists();
128+
var selector = this.selector, direction;
129+
if (direction == 'left' || direction == 'right') {
130+
direction = 'Left';
131+
} else if (direction == 'top' || direction == 'bottom') {
132+
direction = 'Top';
133+
}
134+
FuncUnit.add({
135+
method: function (success, error) {
136+
this.bind.each(function (i, el) {
137+
this['scroll' + direction] = amount;
138+
});
139+
success();
140+
},
141+
success: success,
142+
error: 'Could not scroll ' + this.selector,
143+
bind: this,
144+
type: 'action'
145+
});
146+
return this;
147+
}
148+
});
149+
module.exports = FuncUnit;
150+
});

dist/amd/browser/adapters/adapters.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*[email protected]#browser/adapters/adapters*/
2+
define(function (require, exports, module) {
3+
(function (global) {
4+
var jasmineAdapter = require('./jasmine');
5+
var jasmine2Adapter = require('./jasmine2');
6+
var qunitAdapter = require('./qunit');
7+
var qunit2Adapter = require('./qunit2');
8+
var mochaAdapter = require('./mocha');
9+
var FuncUnit = require('../core');
10+
var noop = function () {
11+
};
12+
var defaultAdapter = {
13+
pauseTest: noop,
14+
resumeTest: noop,
15+
assertOK: noop,
16+
equiv: function (expected, actual) {
17+
return expected == actual;
18+
}
19+
};
20+
FuncUnit.unit = defaultAdapter;
21+
FuncUnit.attach = function (runner) {
22+
var unit;
23+
if (isQUnit(runner)) {
24+
unit = qunitAdapter(runner);
25+
} else if (isQUnit2(runner)) {
26+
unit = qunit2Adapter(runner);
27+
} else if (isMocha(runner)) {
28+
unit = mochaAdapter(runner);
29+
} else if (isJasmine(runner)) {
30+
unit = jasmineAdapter(runner);
31+
} else if (isJasmine2(runner)) {
32+
unit = jasmine2Adapter(runner);
33+
} else {
34+
unit = defaultAdapter;
35+
}
36+
FuncUnit.unit = unit;
37+
};
38+
function isQUnit(runner) {
39+
return !!(runner.ok && runner.start && runner.stop);
40+
}
41+
function isQUnit2(runner) {
42+
return !!(runner.assert && runner.assert.ok && runner.assert.async);
43+
}
44+
function isMocha(runner) {
45+
return !!(runner.setup && runner.globals && runner.reporter);
46+
}
47+
function isJasmine(runner) {
48+
return !!(runner.getEnv && typeof window.waitsFor === 'function');
49+
}
50+
function isJasmine2(runner) {
51+
return !!(runner.getEnv && typeof runner.clock === 'function' && !window.waitsFor);
52+
}
53+
FuncUnit.detach = function () {
54+
FuncUnit.unit = defaultAdapter;
55+
};
56+
}(function () {
57+
return this;
58+
}()));
59+
});

dist/amd/browser/adapters/jasmine.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*[email protected]#browser/adapters/jasmine*/
2+
define(function (require, exports, module) {
3+
module.exports = function (jasmine) {
4+
var paused = false;
5+
return {
6+
pauseTest: function () {
7+
paused = true;
8+
waitsFor(function () {
9+
return paused === false;
10+
}, 60000);
11+
},
12+
resumeTest: function () {
13+
paused = false;
14+
},
15+
assertOK: function (assertion, message) {
16+
expect(assertion).toBeTruthy();
17+
},
18+
equiv: function (expected, actual) {
19+
return jasmine.getEnv().equals_(expected, actual);
20+
}
21+
};
22+
};
23+
});

dist/amd/browser/adapters/jasmine2.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*[email protected]#browser/adapters/jasmine2*/
2+
define(function (require, exports, module) {
3+
var FuncUnit = require('../core');
4+
module.exports = function (jasmine) {
5+
FuncUnit.timeout = 4900;
6+
return {
7+
pauseTest: function () {
8+
},
9+
resumeTest: function () {
10+
},
11+
assertOK: function (assertion, message) {
12+
expect(assertion).toBeTruthy();
13+
},
14+
equiv: function (expected, actual) {
15+
return expected == actual;
16+
}
17+
};
18+
};
19+
});

dist/amd/browser/adapters/mocha.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*[email protected]#browser/adapters/mocha*/
2+
define(function (require, exports, module) {
3+
var FuncUnit = require('../core');
4+
var ok = function (expr, msg) {
5+
if (!expr)
6+
throw new Error(msg);
7+
};
8+
module.exports = function (mocha) {
9+
FuncUnit.timeout = 1900;
10+
return {
11+
pauseTest: function () {
12+
},
13+
resumeTest: function () {
14+
},
15+
assertOK: function (assertion, message) {
16+
ok(assertion, message);
17+
},
18+
equiv: function (expected, actual) {
19+
return expected == actual;
20+
}
21+
};
22+
};
23+
});

dist/amd/browser/adapters/qunit.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*[email protected]#browser/adapters/qunit*/
2+
define(function (require, exports, module) {
3+
module.exports = function (QUnit) {
4+
return {
5+
pauseTest: function () {
6+
QUnit.stop();
7+
},
8+
resumeTest: function () {
9+
QUnit.start();
10+
},
11+
assertOK: function (assertion, message) {
12+
QUnit.ok(assertion, message);
13+
},
14+
equiv: function (expected, actual) {
15+
return QUnit.equiv(expected, actual);
16+
}
17+
};
18+
};
19+
});

dist/amd/browser/adapters/qunit2.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*[email protected]#browser/adapters/qunit2*/
2+
define(function (require, exports, module) {
3+
var FuncUnit = require('../core');
4+
module.exports = function (QUnit) {
5+
var done;
6+
var currentTestAssert;
7+
var originalTest = QUnit.test;
8+
QUnit.test = function funcunitTest(title, test) {
9+
return originalTest(title, function (assert) {
10+
currentTestAssert = assert;
11+
return test.apply(this, arugments);
12+
});
13+
};
14+
return {
15+
pauseTest: function () {
16+
done = currentTestAssert.async();
17+
},
18+
resumeTest: function () {
19+
done();
20+
},
21+
assertOK: function (assertion, message) {
22+
currentTestAssert.ok(assertion, message);
23+
},
24+
equiv: function (expected, actual) {
25+
return QUnit.equiv(expected, actual);
26+
}
27+
};
28+
};
29+
});

0 commit comments

Comments
 (0)