Commit 8ac85d1c authored by tomhuda's avatar tomhuda

Clean up browser build

parent fabe22cb
...@@ -52,6 +52,16 @@ end ...@@ -52,6 +52,16 @@ end
task :dist => ["browser/rsvp.js", "browser/rsvp.min.js", "browser/rsvp.amd.js", "node/rsvp.js"] 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 task :push => :dist do
sh "git add browser/rsvp.js browser/rsvp.min.js browser/rsvp.amd.js" sh "git add browser/rsvp.js browser/rsvp.min.js browser/rsvp.amd.js"
sh "git commit -m 'Updates build artifacts'" sh "git commit -m 'Updates build artifacts'"
...@@ -68,14 +78,17 @@ task :update_tests => "promises-tests" do ...@@ -68,14 +78,17 @@ task :update_tests => "promises-tests" do
end end
end end
desc "Run the tests using Node"
task :test => [:update_tests, "tests/rsvp.js"] do task :test => [:update_tests, "tests/rsvp.js"] do
cd "promises-tests" do cd "promises-tests" do
sh "node ./lib/cli.js ../tests/test-adapter.js" sh "node ./lib/cli.js ../tests/test-adapter.js"
end end
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" sh "open tests/index.html"
end end
desc "Build RSVP.js"
task :default => :dist task :default => :dist
...@@ -2,39 +2,16 @@ ...@@ -2,39 +2,16 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>rsvp.js Tests</title> <title>rsvp.js Tests</title>
<link rel="stylesheet" href="mocha.css" /> <link rel="stylesheet" href="vendor/mocha.css" />
</head> </head>
<body> <body>
<div id="mocha"></div> <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="../browser/rsvp.js"></script>
<script src="test-adapter.js"></script> <script src="vendor/assert.js"></script>
<script> <script src="vendor/mocha.js"></script>
var global = window;
var exports = testThreeCases = {};
</script>
<script src="../promises-tests/lib/tests/helpers/testThreeCases.js"></script>
<script>window.exports = undefined;</script>
<script>mocha.setup({ ui: 'bdd', timeout: 200 })</script> <script>mocha.setup({ ui: 'bdd', timeout: 200 })</script>
<script src="tmp/test-bundle.js"></script>
<script src="extension-tests.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> <script>
mocha.run(); mocha.run();
</script> </script>
......
...@@ -283,4 +283,5 @@ function configure(name, value) { ...@@ -283,4 +283,5 @@ function configure(name, value) {
exports.Promise = Promise; exports.Promise = Promise;
exports.Event = Event; exports.Event = Event;
exports.EventTarget = EventTarget; exports.EventTarget = EventTarget;
exports.all = all;
exports.configure = configure; exports.configure = configure;
/*global RSVP*/ /*global RSVP*/
(function(global) { 'use strict';
'use strict';
var Promise = require('./rsvp').Promise; var Promise;
var adapter;
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') { if (typeof RSVP !== 'undefined') {
adapter = exports; // Test the browser build
} else { Promise = RSVP.Promise;
global.adapter = adapter = {}; } 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(); var promise = new Promise();
promise.resolve(value); promise.resolve(value);
return promise; return promise;
}; };
adapter.rejected = function(error) { adapter.rejected = function(error) {
var promise = new Promise(); var promise = new Promise();
promise.reject(error); promise.reject(error);
return promise; return promise;
}; };
adapter.pending = function () { adapter.pending = function () {
var promise = new Promise(); var promise = new Promise();
return { return {
...@@ -36,5 +38,6 @@ ...@@ -36,5 +38,6 @@
promise.reject(error); promise.reject(error);
} }
}; };
}; };
})(this);
module.exports = global.adapter = adapter;
This diff is collapsed.
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