Permalink
Browse files

add unit tests for dependent modules

  • Loading branch information...
1 parent 9da71bf commit 8cef30e176675a6176b548304dfb22bec5a4f9da @jhudson8 jhudson8 committed Jan 7, 2013
Showing with 52 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +2 −0 lumbar.json
  3. +1 −0 test/js/depends-on-this.js
  4. +7 −0 test/js/depends.js
  5. +27 −0 test/js/loader-test.js
  6. +14 −0 test/loader-test.json
View
@@ -1,2 +1,3 @@
build
node_modules
+.npm-debug.log
View
@@ -8,6 +8,7 @@
"lumbar-loader": {
"scripts": [
{"src": "lib/script.js", "global": true, "combined": false},
+ {"src": "lib/queue.js", "global": true},
{"src": "local-cache.js", "global": true},
{"src": "lumbar-loader.js"},
{"src": "lumbar-loader-events.js"},
@@ -22,6 +23,7 @@
// rules in place make developing with this loader quite problematic.
"lumbar-localstorage-loader": {
"scripts": [
+ {"src": "lib/queue.js", "global": true},
{"src": "local-cache.js", "global": true},
{"src": "lumbar-loader.js"},
{"src": "lumbar-loader-events.js"},
@@ -0,0 +1 @@
+window.dependsLoaded = true;
View
@@ -0,0 +1,7 @@
+new (Backbone.Router.extend({
+ routes: module.routes,
+
+ hasDepends: function() {
+ LoaderTest.trigger('load', 'has-depends');
+ }
+}));
View
@@ -116,5 +116,32 @@ lumbarLoader.loadComplete = function(name) {
Backbone.history.navigate('moduleNoRoute', true);
});
+
+ QUnit.asyncTest('module dependancies', function() {
+ QUnit.equal(window.dependsLoaded, undefined);
+ LoaderTest.bind('load', function(fragment) {
+ QUnit.equal(fragment, 'has-depends');
+ QUnit.equal(window.dependsLoaded, true);
+ Backbone.history.navigate('');
+ });
+
+ Backbone.history.navigate('has-depends', true);
+ QUnit.start();
+/*
+ LoaderTest.bind('load', function(fragment) {
+ QUnit.equal('has-depends', fragment, 'Fragment is correct module');
+
+ QUnit.notEqual(window.LoaderTest.module1, undefined, 'module is loaded');
+ QUnit.equal(document.styleSheets.length, 3, 'stylesheet is loaded');
+ QUnit.equal(getSelector(2, 0), '.module1', 'stylesheet is QUnit.expected');
+ QUnit.deepEqual(window.failedModules, []);
+
+ QUnit.start();
+ });
+ Backbone.history.navigate('has-depends', true);
+*/
+ });
+
+
document.getElementById('lumbar-modules-loaded').innerHTML = 'modules loaded';
};
View
@@ -89,6 +89,20 @@
"js/module1.js"
]
},
+ "module-depends-on-this": {
+ "scripts": [
+ "js/depends-on-this.js"
+ ]
+ },
+ "module-depends": {
+ "depends": ["module-depends-on-this"],
+ "routes": {
+ "has-depends": "hasDepends"
+ },
+ "scripts": [
+ "js/depends.js"
+ ]
+ },
"module-subsequent": {
"topLevelName": "ModuleDelay",
"scripts": [

0 comments on commit 8cef30e

Please sign in to comment.