Commit 8ac85d1c authored by tomhuda's avatar tomhuda

Clean up browser build

parent fabe22cb
......@@ -52,6 +52,16 @@ end
task :dist => ["browser/rsvp.js", "browser/rsvp.min.js", "browser/rsvp.amd.js", "node/rsvp.js"]
directory "tests/tmp"
test_files = ["tests/test-adapter.js"]
test_files += Dir["promises-tests/lib/tests/**/*.js"]
test_files += Dir["promises-tests/node_modules/sinon/lib/{sinon.js,sinon/*.js}"]
file "tests/tmp/test-bundle.js" => ["tests/tmp"].concat(test_files) do
sh "browserify #{test_files.join(" ")} > tests/tmp/test-bundle.js"
end
task :push => :dist do
sh "git add browser/rsvp.js browser/rsvp.min.js browser/rsvp.amd.js"
sh "git commit -m 'Updates build artifacts'"
......@@ -68,14 +78,17 @@ task :update_tests => "promises-tests" do
end
end
desc "Run the tests using Node"
task :test => [:update_tests, "tests/rsvp.js"] do
cd "promises-tests" do
sh "node ./lib/cli.js ../tests/test-adapter.js"
end
end
task :browser_test => [:update_tests, :dist] do
desc "Run the tests using the browser"
task :browser_test => [:update_tests, "tests/tmp/test-bundle.js", :dist] do
sh "open tests/index.html"
end
desc "Build RSVP.js"
task :default => :dist
......@@ -2,39 +2,16 @@
<head>
<meta charset="utf-8">
<title>rsvp.js Tests</title>
<link rel="stylesheet" href="mocha.css" />
<link rel="stylesheet" href="vendor/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script>
var require = function(name) {
switch(name) {
case "assert": return window.assert;
case "sinon": return window.sinon;
case "./helpers/testThreeCases": return window.testThreeCases;
case "./rsvp": return RSVP;
}
};
</script>
<script src="assert.js"></script>
<script src="sinon.js"></script>
<script src="mocha.js"></script>
<script src="../browser/rsvp.js"></script>
<script src="test-adapter.js"></script>
<script>
var global = window;
var exports = testThreeCases = {};
</script>
<script src="../promises-tests/lib/tests/helpers/testThreeCases.js"></script>
<script>window.exports = undefined;</script>
<script src="vendor/assert.js"></script>
<script src="vendor/mocha.js"></script>
<script>mocha.setup({ ui: 'bdd', timeout: 200 })</script>
<script src="tmp/test-bundle.js"></script>
<script src="extension-tests.js"></script>
<script src="../promises-tests/lib/tests/3.2.1.js"></script>
<script src="../promises-tests/lib/tests/3.2.2.js"></script>
<script src="../promises-tests/lib/tests/3.2.3.js"></script>
<script src="../promises-tests/lib/tests/3.2.4.js"></script>
<script src="../promises-tests/lib/tests/3.2.5.js"></script>
<script src="../promises-tests/lib/tests/3.2.6.js"></script>
<script>
mocha.run();
</script>
......
......@@ -283,4 +283,5 @@ function configure(name, value) {
exports.Promise = Promise;
exports.Event = Event;
exports.EventTarget = EventTarget;
exports.all = all;
exports.configure = configure;
/*global RSVP*/
(function(global) {
'use strict';
'use strict';
var Promise = require('./rsvp').Promise;
var adapter;
var Promise;
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
adapter = exports;
} else {
global.adapter = adapter = {};
}
if (typeof RSVP !== 'undefined') {
// Test the browser build
Promise = RSVP.Promise;
} else {
// Test the Node build
var Promise = require('../node/rsvp').Promise;
}
var adapter = {};
adapter.fulfilled = function(value) {
adapter.fulfilled = function(value) {
var promise = new Promise();
promise.resolve(value);
return promise;
};
};
adapter.rejected = function(error) {
adapter.rejected = function(error) {
var promise = new Promise();
promise.reject(error);
return promise;
};
};
adapter.pending = function () {
adapter.pending = function () {
var promise = new Promise();
return {
......@@ -36,5 +38,6 @@
promise.reject(error);
}
};
};
})(this);
};
module.exports = global.adapter = adapter;
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment