-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from lyt9304/adapt-to-ie8
将单元测试代码适配到 IE8 + jQuery 环境
- Loading branch information
Showing
13 changed files
with
522 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Testing Sandbox - UT - Gearbox</title> | ||
</head> | ||
|
||
<body> | ||
<h1>Testing Sandbox</h1> | ||
<script src="../bower_components/underscore/underscore.js"></script> | ||
<script src="../bower_components/jquery/dist/jquery.js"></script> | ||
<script src="../dist/gearbox.js"></script> | ||
<script> | ||
void function () { | ||
'use strict' | ||
|
||
var conditions = JSON.parse(window.name || '{}') | ||
var testId = conditions.testId | ||
var keysToBeTested = conditions.keysToBeTested | ||
if (!testId) return | ||
|
||
var result = {} | ||
// `JSON.stringify()` drops undefined keys in objects, so we need save these keys separately. | ||
var emptyKeys = [] | ||
|
||
_.each(keysToBeTested, function (item) { | ||
var value = _.url.getParam(item) | ||
if (typeof value === 'undefined') { | ||
emptyKeys.push(item) | ||
} else { | ||
result[item] = value | ||
} | ||
}) | ||
|
||
var data = { | ||
testId: testId, | ||
result: result, | ||
emptyKeys: emptyKeys | ||
} | ||
parent.postMessage(JSON.stringify(data), '*') | ||
|
||
}() | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>UT (Trad) (jQuery) - Gearbox</title> | ||
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> | ||
<link rel="stylesheet" href="../bower_components/mocha/mocha.css"> | ||
<link rel="stylesheet" href="../bower_components/mocha.css/src/mocha.css"> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>UT (Trad) (jQuery) - Gearbox</h1> | ||
<p><a href="https://github.com/CMUI/gearbox">View on GitHub</a></p> | ||
</header> | ||
<div id="mocha"></div> | ||
<!-- deps --> | ||
<script src="../bower_components/underscore/underscore.js"></script> | ||
<script src="../bower_components/jquery/dist/jquery.js"></script> | ||
<!-- testing framework --> | ||
<script src="../bower_components/mocha/mocha.js"></script> | ||
<script src="../bower_components/expect.js/index.js"></script> | ||
<script> | ||
mocha.setup('bdd') | ||
mocha.checkLeaks() | ||
</script> | ||
<!-- traditional package --> | ||
<script src="../dist/gearbox.js"></script> | ||
<!-- test-case --> | ||
<script src="test-str-alt.js"></script> | ||
<script src="test-str.js"></script> | ||
<script src="test-root.js"></script> | ||
<script src="test-ua.js"></script> | ||
<script src="test-url.js"></script> | ||
<script src="test-dom.js"></script> | ||
<script src="test-action.js"></script> | ||
<script src="test-template.js"></script> | ||
<!-- init --> | ||
<script> | ||
// IE 会把 iframe 的 ID 映射为 window 上的一个属性, 导致全局变量泄漏. | ||
// 因此需要在 mocha 中提前注册一下 iframe 的 ID. | ||
mocha.globals(['sandbox']) | ||
mocha.run() | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.