can
Version:
MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.
123 lines (118 loc) • 3.78 kB
HTML
<html>
<head>
<script>
// The "loader" package depends on the package "pkg"; the application also
// depends on the package "pkg", but configured in a different way. Therefore, solve
// the problem by mapping "pkg" as seen by "loader" to "pkgMapped". Then configure
// the packages "pkg" and "pkgMapped" differently.
//
// At the app (global) level, config can be accomplished via the names "pkg" and "pkgMapped".
// Notice also that "pkg" does some of it's own configuration based on user configuration.
// This tests the ability to configure a mapped package.
var dojoConfig = {
async:1,
baseUrl:"../../../../..",
packages:[{
name:"loader",
location:"dojo/tests/_base/loader/config",
packageMap:{
"pkg":"pkgMapped"
}
},{
name:"pkg",
location:"dojo/tests/_base/loader/config/pkg"
},{
name:"pkgMapped",
location:"dojo/tests/_base/loader/config/pkg",
packageMap:{
"pkg":"pkgMapped"
}
},{
name:"dojo",
location:"dojo"
},{
name:"doh",
location:"util/doh"
}],
config:{
"loader/someModuleConfiggedPriorToBoot":{someConfig:"this is the config for someModuleConfiggedPriorToBoot"}
},
deps:["doh"],
callback:function(doh){
var master = new doh.Deferred(), waiting = 2;
doh.register(
"require.config",
[
{
name: "require.config",
timeout: 5000,
runTest: function() {
return master;
}
}
]
);
doh.run();
require({config:{
"loader/someModule":{someConfig:"this is the config for someModule-someConfig"},
"pkgMapped/m1":{globalConfig:"globalConfigForpkgMapped/m1", isMapped:true},
"pkgMapped/m2":{globalConfig:"globalConfigForpkgMapped/m2"}
}});
require(["loader/someModuleConfiggedPriorToBoot", "loader/someModule"], function(someModuleConfiggedPriorToBoot, someModule){
doh.is(someModuleConfiggedPriorToBoot.getConfig(), {
someConfig:"this is the config for someModuleConfiggedPriorToBoot"});
doh.is(someModule.getConfig(), {
someConfig:"this is the config for someModule-someConfig"});
doh.is(someModule.m1.getConfig(), {
globalConfig:"globalConfigForpkgMapped/m1",
isMapped:true,
configThroughMappedRefForM1:"configThroughMappedRefForM1"});
doh.is(someModule.m2.getConfig(), {
globalConfig:"globalConfigForpkgMapped/m2",
configThroughMappedRefForM1:"configThroughMappedRefForM1",
config1:"mapped-config1",
config2:"mapped-config2",
config3:"mapped-config3"
});
setTimeout(function(){
require({
config:{
"loader/someModule":{
someMoreConfig:"this is the config for someModule-someMoreConfig"
}
}
});
require(["loader/someModule"], function(someModule){
doh.is(someModule.getConfig(), {
someConfig:"this is the config for someModule-someConfig",
someMoreConfig:"this is the config for someModule-someMoreConfig"
});
if(!(--waiting)){
master.callback(true);
}
});
}, 10);
});
require({config:{
"pkg/m1":{globalConfig:"globalConfigForM1"},
"pkg/m2":{globalConfig:"globalConfigForM2"}
}},["pkg/m1", "pkg/m2"], function(m1, m2){
doh.is(m1.getConfig(), {
globalConfig:"globalConfigForM1"});
doh.is(m2.getConfig(), {
globalConfig:"globalConfigForM2",
config1:"config1",
config2:"config2",
config3:"config3"
});
if(!(--waiting)){
master.callback(true);
}
});
doh.run();
}
};
</script>
<script src="../../../../dojo.js"></script>
</head>
</html>