Skip to content

Commit 98d2733

Browse files
authored
Merge branch 'master' into greenkeeper/initial
2 parents f6a4ba7 + 0216ae2 commit 98d2733

21 files changed

+8843
-30
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ guides/
1010
!doc/guides/
1111
site/node_modules/
1212
!site/lib/
13-
!site/**/lib/
13+
!site/**/lib/
14+
.idea/
15+
static
16+
index.html

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ publish-docs:
99
./node_modules/.bin/documentjs --f
1010
git add -f docs/
1111
git add -f guides/
12-
git add -f site/
12+
git add -f site/static/
1313
git add -f examples/
1414
git add -f index.html
1515
git add -f CNAME
1616
git commit -m "Publish docs"
1717
git push -f origin gh-pages
1818
git checkout -
19-
git branch -D gh-pages
19+
git branch -D gh-pages

browser/adapters/adapters.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var jasmineAdapter = require("funcunit/browser/adapters/jasmine");
22
var jasmine2Adapter = require("funcunit/browser/adapters/jasmine2");
33
var qunitAdapter = require("funcunit/browser/adapters/qunit");
4+
var qunit2Adapter = require("funcunit/browser/adapters/qunit2");
45
var mochaAdapter = require("funcunit/browser/adapters/mocha");
56
var FuncUnit = require("funcunit/browser/core");
67

@@ -68,6 +69,8 @@ FuncUnit.attach = function(runner){
6869
var unit;
6970
if(isQUnit(runner)) {
7071
unit = qunitAdapter(runner);
72+
} else if(isQUnit2(runner)) {
73+
unit = qunit2Adapter(runner);
7174
} else if(isMocha(runner)) {
7275
unit = mochaAdapter(runner);
7376
} else if(isJasmine(runner)) {
@@ -85,6 +88,10 @@ function isQUnit(runner) {
8588
return !!(runner.ok && runner.start && runner.stop);
8689
}
8790

91+
function isQUnit2(runner) {
92+
return !!(runner.assert && runner.assert.ok && runner.assert.async);
93+
}
94+
8895
function isMocha(runner) {
8996
return !!(runner.setup && runner.globals && runner.reporter);
9097
}

browser/adapters/qunit2.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var FuncUnit = require("funcunit/browser/core");
2+
3+
module.exports = function(QUnit){
4+
var done;
5+
6+
return {
7+
pauseTest:function(){
8+
done = FuncUnit.qunit2Assert.async();
9+
},
10+
resumeTest: function(){
11+
done();
12+
},
13+
assertOK: function(assertion, message){
14+
FuncUnit.qunit2Assert.ok(assertion, message)
15+
},
16+
equiv: function(expected, actual){
17+
return QUnit.equiv(expected, actual);
18+
}
19+
};
20+
};

browser/core.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ FuncUnit = function( selector, frame ) {
2222
}
2323

2424
isSyncOnly = typeof forceSync === "boolean"? forceSync: isSyncOnly;
25+
26+
assignQunit2Assert(FuncUnit);
27+
2528
// if its a function, just run it in the queue
2629
if(typeof selector == "function"){
2730
return FuncUnit.wait(0, selector);
@@ -39,8 +42,6 @@ FuncUnit = function( selector, frame ) {
3942
}
4043
}
4144

42-
43-
4445
var getContext = function(context){
4546
if (typeof context === "number" || typeof context === "string") {
4647
// try to get the context from an iframe in the funcunit document
@@ -79,6 +80,14 @@ var getContext = function(context){
7980
return obj;
8081
}
8182

83+
var assignQunit2Assert = function (func) {
84+
var callerFirstArgument = func.caller.arguments[0];
85+
86+
if(callerFirstArgument && callerFirstArgument.test){
87+
FuncUnit.qunit2Assert = callerFirstArgument;
88+
}
89+
};
90+
8291
oldFuncUnit.jQuery.extend(FuncUnit, oldFuncUnit, origFuncUnit)
8392
FuncUnit.prototype = origFuncUnit.prototype;
8493
module.exports = FuncUnit;

browser/init.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var jQuery = require("funcunit/browser/jquery");
22

33
var FuncUnit = window.FuncUnit || {};
4-
window.jQuery = jQuery;
54

65
jQuery.sub = function() {
76
function jQuerySub( selector, context ) {

browser/waits.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ FuncUnit.
2323
* but before any more queued actions.
2424
*/
2525
wait = function(time, success){
26+
assignQunit2Assert(FuncUnit.wait);
2627
if(typeof time == 'function'){
2728
success = time;
2829
time = undefined;
@@ -68,6 +69,7 @@ FuncUnit.
6869
* @param {Number} timeout if neither checker returns true before this timeout, the test fails
6970
*/
7071
branch = function(check1, success1, check2, success2, timeout){
72+
assignQunit2Assert(FuncUnit.branch);
7173
FuncUnit.repeat({
7274
method : function(print){
7375
print("Running a branch statement")
@@ -99,7 +101,7 @@ branch = function(check1, success1, check2, success2, timeout){
99101
bind: this
100102
*/
101103
FuncUnit.repeat = function(options){
102-
104+
assignQunit2Assert(FuncUnit.repeat);
103105
var interval,
104106
stopped = false ,
105107
stop = function(){
@@ -155,13 +157,22 @@ FuncUnit.repeat = function(options){
155157
* if the tested page has jQuery present.
156158
*/
157159
FuncUnit.animationEnd = function(){
160+
assignQunit2Assert(FuncUnit.animationEnd);
158161
F("body").wait(200).size(function(){
159162
return F.win.$(':animated').length === 0;
160163
});
161164
};
162165

163166
FuncUnit.animationsDone = FuncUnit.animationEnd;
164167

168+
var assignQunit2Assert = function (func) {
169+
var callerFirstArgument = func.caller.arguments[0];
170+
171+
if(callerFirstArgument && callerFirstArgument.test){
172+
FuncUnit.qunit2Assert = callerFirstArgument;
173+
}
174+
};
175+
165176
$.extend(FuncUnit.prototype, {
166177
/**
167178
* @function FuncUnit.prototype.exists .exists()

build.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ var parseModuleName = npmUtils.moduleName.parse;
55

66
stealTools.export({
77
system: {
8-
config: __dirname + "/package.json!npm"
8+
config: __dirname + "/package.json!npm",
9+
"main": "global"
910
},
1011
outputs: {
1112
"+amd": {},
1213
"+cjs": {},
1314
"global": {
14-
modules: ["funcunit"],
15+
modules: ["global"],
1516
dest: __dirname + "/dist/funcunit.js",
1617
format: "global",
1718
normalize: function(depName) {

documentjs.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@
1515
},
1616
"parent": "Guides",
1717
"pageConfig": {"page":"guides"}
18+
},
19+
"funcunit": {
20+
"glob": {
21+
"pattern": "funcunit.md"
22+
},
23+
"templates": "main"
1824
}
1925
},
2026
"siteDefaults": {
2127
"static":"site/theme/static",
2228
"templates": "site/theme/templates"
2329
}
24-
}
30+
}

funcunit.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@page funcunit FuncUnit
2+
3+
@body

0 commit comments

Comments
 (0)