Skip to content

Commit

Permalink
3.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
chasenlehara committed Oct 24, 2017
1 parent 2ba539b commit e46f461
Show file tree
Hide file tree
Showing 35 changed files with 11,830 additions and 0 deletions.
150 changes: 150 additions & 0 deletions dist/amd/browser/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*[email protected]#browser/actions*/
define(function (require, exports, module) {
var $ = require('./jquery');
var FuncUnit = require('./core');
var syn = window.syn = require('syn');
var clicks = [
'click',
'dblclick',
'rightClick'
], makeClick = function (name) {
FuncUnit.prototype[name] = function (options, success) {
this._addExists();
if (typeof options == 'function') {
success = options;
options = {};
}
var selector = this.selector;
FuncUnit.add({
method: function (success, error) {
options = options || {};
syn('_' + name, this.bind[0], options, success);
},
success: success,
error: 'Could not ' + name + ' \'' + this.selector + '\'',
bind: this,
type: 'action'
});
return this;
};
};
for (var i = 0; i < clicks.length; i++) {
makeClick(clicks[i]);
}
$.extend(FuncUnit.prototype, {
_addExists: function () {
this.exists(false);
},
type: function (text, success) {
this._addExists();
this.click();
var selector = this.selector;
if (text === '') {
text = '[ctrl]a[ctrl-up]\b';
}
FuncUnit.add({
method: function (success, error) {
syn('_type', this.bind[0], text, success);
},
success: success,
error: 'Could not type ' + text + ' into ' + this.selector,
bind: this,
type: 'action'
});
return this;
},
sendKeys: function (keys, success) {
this._addExists();
var selector = this.selector;
if (keys === '') {
keys = '[ctrl]a[ctrl-up]\b';
}
FuncUnit.add({
method: function (success, error) {
syn('_type', this.bind[0], keys, success);
},
success: success,
error: 'Could not send the keys ' + keys + ' into ' + this.selector,
bind: this,
type: 'action'
});
return this;
},
trigger: function (evName, success) {
this._addExists();
FuncUnit.add({
method: function (success, error) {
if (!FuncUnit.win.jQuery) {
throw 'Can not trigger custom event, no jQuery found on target page.';
}
FuncUnit.win.jQuery(this.bind.selector).trigger(evName);
success();
},
success: success,
error: 'Could not trigger ' + evName,
bind: this,
type: 'action'
});
return this;
},
drag: function (options, success) {
this._addExists();
if (typeof options == 'string') {
options = { to: options };
}
options.from = this.selector;
var selector = this.selector;
FuncUnit.add({
method: function (success, error) {
syn('_drag', this.bind[0], options, success);
},
success: success,
error: 'Could not drag ' + this.selector,
bind: this,
type: 'action'
});
return this;
},
move: function (options, success) {
this._addExists();
if (typeof options == 'string') {
options = { to: options };
}
options.from = this.selector;
var selector = this.selector;
FuncUnit.add({
method: function (success, error) {
syn('_move', this.bind[0], options, success);
},
success: success,
error: 'Could not move ' + this.selector,
bind: this,
type: 'action'
});
return this;
},
scroll: function (direction, amount, success) {
this._addExists();
var selector = this.selector, direction;
if (direction == 'left' || direction == 'right') {
direction = 'Left';
} else if (direction == 'top' || direction == 'bottom') {
direction = 'Top';
}
FuncUnit.add({
method: function (success, error) {
this.bind.each(function (i, el) {
this['scroll' + direction] = amount;
});
success();
},
success: success,
error: 'Could not scroll ' + this.selector,
bind: this,
type: 'action'
});
return this;
}
});
module.exports = FuncUnit;
});
59 changes: 59 additions & 0 deletions dist/amd/browser/adapters/adapters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*[email protected]#browser/adapters/adapters*/
define(function (require, exports, module) {
(function (global) {
var jasmineAdapter = require('./jasmine');
var jasmine2Adapter = require('./jasmine2');
var qunitAdapter = require('./qunit');
var qunit2Adapter = require('./qunit2');
var mochaAdapter = require('./mocha');
var FuncUnit = require('../core');
var noop = function () {
};
var defaultAdapter = {
pauseTest: noop,
resumeTest: noop,
assertOK: noop,
equiv: function (expected, actual) {
return expected == actual;
}
};
FuncUnit.unit = defaultAdapter;
FuncUnit.attach = function (runner) {
var unit;
if (isQUnit(runner)) {
unit = qunitAdapter(runner);
} else if (isQUnit2(runner)) {
unit = qunit2Adapter(runner);
} else if (isMocha(runner)) {
unit = mochaAdapter(runner);
} else if (isJasmine(runner)) {
unit = jasmineAdapter(runner);
} else if (isJasmine2(runner)) {
unit = jasmine2Adapter(runner);
} else {
unit = defaultAdapter;
}
FuncUnit.unit = unit;
};
function isQUnit(runner) {
return !!(runner.ok && runner.start && runner.stop);
}
function isQUnit2(runner) {
return !!(runner.assert && runner.assert.ok && runner.assert.async);
}
function isMocha(runner) {
return !!(runner.setup && runner.globals && runner.reporter);
}
function isJasmine(runner) {
return !!(runner.getEnv && typeof window.waitsFor === 'function');
}
function isJasmine2(runner) {
return !!(runner.getEnv && typeof runner.clock === 'function' && !window.waitsFor);
}
FuncUnit.detach = function () {
FuncUnit.unit = defaultAdapter;
};
}(function () {
return this;
}()));
});
23 changes: 23 additions & 0 deletions dist/amd/browser/adapters/jasmine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*[email protected]#browser/adapters/jasmine*/
define(function (require, exports, module) {
module.exports = function (jasmine) {
var paused = false;
return {
pauseTest: function () {
paused = true;
waitsFor(function () {
return paused === false;
}, 60000);
},
resumeTest: function () {
paused = false;
},
assertOK: function (assertion, message) {
expect(assertion).toBeTruthy();
},
equiv: function (expected, actual) {
return jasmine.getEnv().equals_(expected, actual);
}
};
};
});
19 changes: 19 additions & 0 deletions dist/amd/browser/adapters/jasmine2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*[email protected]#browser/adapters/jasmine2*/
define(function (require, exports, module) {
var FuncUnit = require('../core');
module.exports = function (jasmine) {
FuncUnit.timeout = 4900;
return {
pauseTest: function () {
},
resumeTest: function () {
},
assertOK: function (assertion, message) {
expect(assertion).toBeTruthy();
},
equiv: function (expected, actual) {
return expected == actual;
}
};
};
});
23 changes: 23 additions & 0 deletions dist/amd/browser/adapters/mocha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*[email protected]#browser/adapters/mocha*/
define(function (require, exports, module) {
var FuncUnit = require('../core');
var ok = function (expr, msg) {
if (!expr)
throw new Error(msg);
};
module.exports = function (mocha) {
FuncUnit.timeout = 1900;
return {
pauseTest: function () {
},
resumeTest: function () {
},
assertOK: function (assertion, message) {
ok(assertion, message);
},
equiv: function (expected, actual) {
return expected == actual;
}
};
};
});
19 changes: 19 additions & 0 deletions dist/amd/browser/adapters/qunit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*[email protected]#browser/adapters/qunit*/
define(function (require, exports, module) {
module.exports = function (QUnit) {
return {
pauseTest: function () {
QUnit.stop();
},
resumeTest: function () {
QUnit.start();
},
assertOK: function (assertion, message) {
QUnit.ok(assertion, message);
},
equiv: function (expected, actual) {
return QUnit.equiv(expected, actual);
}
};
};
});
29 changes: 29 additions & 0 deletions dist/amd/browser/adapters/qunit2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*[email protected]#browser/adapters/qunit2*/
define(function (require, exports, module) {
var FuncUnit = require('../core');
module.exports = function (QUnit) {
var done;
var currentTestAssert;
var originalTest = QUnit.test;
QUnit.test = function funcunitTest(title, test) {
return originalTest(title, function (assert) {
currentTestAssert = assert;
return test.apply(this, arugments);
});
};
return {
pauseTest: function () {
done = currentTestAssert.async();
},
resumeTest: function () {
done();
},
assertOK: function (assertion, message) {
currentTestAssert.ok(assertion, message);
},
equiv: function (expected, actual) {
return QUnit.equiv(expected, actual);
}
};
};
});
Loading

0 comments on commit e46f461

Please sign in to comment.