Comparing version 0.2.0 to 0.3.0
@@ -6,7 +6,11 @@ function quote(t) { | ||
function amdWrapper(paths, mapper) { | ||
var tests = paths.map(mapper).map(quote).join(", "); | ||
var tests = paths.map(mapper).map(quote); | ||
var identifiers = paths.map(function (t, i) { return "t" + i; }); | ||
return "require([" + tests + "], function(" + identifiers.join(", ") + | ||
") {\n console.log('loading');\n buster.run();\n});"; | ||
tests.unshift("'buster'"); | ||
identifiers.unshift('buster'); | ||
return "define('buster', function(){ return buster; });"+ | ||
"require([" + tests.join(", ") + "], function(" + identifiers.join(", ") + | ||
") {\n buster.run();\n});"; | ||
} | ||
@@ -23,2 +27,4 @@ | ||
}; | ||
ext.preloadSources = !!options.preloadSources; | ||
ext.preloadTests = !!options.preloadTests; | ||
return ext; | ||
@@ -28,16 +34,20 @@ }, | ||
configure: function (conf) { | ||
conf.options.autoRun = false; | ||
conf.options.autoRun = false; | ||
conf.on("load:tests", function (rs) { | ||
var paths = rs.loadPath.paths(); | ||
rs.addResource({ | ||
rs.addResource({ | ||
path: "/buster/load-all.js", | ||
content: amdWrapper(rs.loadPath.paths(), this.pathMapper) | ||
}); | ||
rs.loadPath.clear(); | ||
rs.loadPath.append("/buster/load-all.js"); | ||
content: amdWrapper(rs.loadPath.paths(), this.pathMapper) | ||
}); | ||
if (!this.preloadTests) { | ||
rs.loadPath.clear(); | ||
} | ||
rs.loadPath.append("/buster/load-all.js"); | ||
}.bind(this)); | ||
conf.on("load:sources", function (rs) { rs.loadPath.clear(); }); | ||
if (!this.preloadSources) { | ||
conf.on("load:sources", function (rs) { rs.loadPath.clear(); }); | ||
} | ||
} | ||
}; |
{ | ||
"name": "buster-amd", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Extension for testing AMD modules", | ||
@@ -21,3 +21,3 @@ "homepage": "http://busterjs.org/docs/buster-amd", | ||
"dependencies": { | ||
"buster-core": ">=0.5.1" | ||
"buster-core": ">=0.6.0" | ||
}, | ||
@@ -27,2 +27,2 @@ "devDependencies": { | ||
} | ||
} | ||
} |
@@ -17,5 +17,5 @@ var buster = require("buster"); | ||
body.extensions = [amd]; | ||
group = c.create().addGroup("test", body, __dirname + "/fixtures"); | ||
group = c.createConfiguration().addGroup("test", body, __dirname + "/fixtures"); | ||
group.bundleFramework().resolve().then(function (resourceSet) { | ||
group.resolve().then(function (resourceSet) { | ||
rs = resourceSet; | ||
@@ -49,4 +49,4 @@ var paths = resourceSet.loadPath.paths(); | ||
"loader module requires dependenceis": function() { | ||
assert.match(content(), /^require\(\[\]/); | ||
"loader module requires dependencies": function() { | ||
assert.match(content(), /require\(\['buster'\]/); | ||
}, | ||
@@ -60,2 +60,10 @@ | ||
})); | ||
}, | ||
"loader module defines buster as a module": function() { | ||
assert.match(content(), /define\('buster',/); | ||
}, | ||
"loader module declares buster as function parameter": function() { | ||
assert.match(content(), /function\(buster\)/); | ||
} | ||
@@ -75,7 +83,7 @@ }; | ||
"depends on tests from loader module" : function() { | ||
assert.match(content(), "'foo-test', 'bar-test'"); | ||
assert.match(content(), "'buster', 'foo-test', 'bar-test'"); | ||
}, | ||
"dependencies are declares as function parameters" : function() { | ||
assert.match(content(), /function\(.+, .+\)/); | ||
"dependencies are declared as function parameters" : function() { | ||
assert.match(content(), /function\(buster, .+, .+\)/); | ||
}, | ||
@@ -119,4 +127,36 @@ | ||
}; | ||
}) | ||
}), | ||
"preloadSources": withGroup({ | ||
sources: ["foo-test.js"], | ||
tests: ["bar-test.js"], | ||
"buster-amd": { | ||
preloadSources: true | ||
} | ||
}, function(group, rs, err, content, tests) { | ||
return { | ||
"sources not removed from load path": function() { | ||
assert.equals( | ||
rs().loadPath.paths(), | ||
["/foo-test.js", "/buster/load-all.js"]); | ||
} | ||
}; | ||
}), | ||
"preloadTests": withGroup({ | ||
sources: ["foo-test.js"], | ||
tests: ["bar-test.js"], | ||
"buster-amd": { | ||
preloadTests: true | ||
} | ||
}, function(group, rs, err, content, tests) { | ||
return { | ||
"tests not removed from load path": function() { | ||
assert.equals( | ||
rs().loadPath.paths(), | ||
["/bar-test.js", "/buster/load-all.js"]); | ||
} | ||
}; | ||
}) | ||
} | ||
}); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
336493
9577
3
Updatedbuster-core@>=0.6.0