Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a subset of the mapConfig tests from requirejs #10

Merged
merged 2 commits into from
Sep 11, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/mapConfig/a1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define(['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
6 changes: 6 additions & 0 deletions tests/mapConfig/a1/sub/one.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define(['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
4 changes: 4 additions & 0 deletions tests/mapConfig/adapter/d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
define(['d'], function(d) {
d.adapted = true;
return d;
});
6 changes: 6 additions & 0 deletions tests/mapConfig/another/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define(['./minor'], function (minor) {
return {
name: 'another/c',
minorName: minor.name
};
});
3 changes: 3 additions & 0 deletions tests/mapConfig/another/c/dim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define({
name: 'another/c/dim'
});
6 changes: 6 additions & 0 deletions tests/mapConfig/another/c/sub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define(['./dim'], function (dim) {
return {
name: 'another/c/sub',
dimName: dim.name
};
});
4 changes: 4 additions & 0 deletions tests/mapConfig/another/minor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
define({
name: 'another/minor'
});

6 changes: 6 additions & 0 deletions tests/mapConfig/b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define(['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
3 changes: 3 additions & 0 deletions tests/mapConfig/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define({
name: 'c'
});
3 changes: 3 additions & 0 deletions tests/mapConfig/c/sub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define({
name: 'c/sub'
});
3 changes: 3 additions & 0 deletions tests/mapConfig/c1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define({
name: 'c1'
});
3 changes: 3 additions & 0 deletions tests/mapConfig/c1/sub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define({
name: 'c1/sub'
});
3 changes: 3 additions & 0 deletions tests/mapConfig/c2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define({
name: 'c2'
});
3 changes: 3 additions & 0 deletions tests/mapConfig/c2/sub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define({
name: 'c2/sub'
});
3 changes: 3 additions & 0 deletions tests/mapConfig/d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define({
name: 'd'
});
6 changes: 6 additions & 0 deletions tests/mapConfig/e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define(['d'], function (d) {
return {
name: 'e',
d: d
};
});
33 changes: 33 additions & 0 deletions tests/mapConfig/mapConfig-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
config({
baseUrl: './',
paths: {
a: 'a1'
},
map: {
'a': {
c: 'c1'
},
'a/sub/one': {
'c': 'c2'
}
}
});
go(['a', 'b', 'c', 'a/sub/one'],
function(a, b, c, one) {
doh.register(
'mapConfig',
[
function mapConfig(t){
t.is('c1', a.c.name);
t.is('c1/sub', a.csub.name);
t.is('c2', one.c.name);
t.is('c2/sub', one.csub.name);
t.is('c', b.c.name);
t.is('c/sub', b.csub.name);
t.is('c', c.name);
}
]
);
doh.run();
}
);
13 changes: 13 additions & 0 deletions tests/mapConfig/mapConfig.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>Map Config Test</title>
<script type="text/javascript" src="../bootstrap.js"></script>
<script type="text/javascript" src="mapConfig-tests.js"></script>
</head>
<body>
<h1>Map Config Test</h1>
<p>Test using the map config.</p>
<p>Check console for messages</p>
</body>
</html>
41 changes: 41 additions & 0 deletions tests/mapConfig/mapConfigStar-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
config({
baseUrl: './',
paths: {
a: 'a1'
},

map: {
'*': {
'c': 'another/c'
},
'a': {
c: 'c1'
},
'a/sub/one': {
'c': 'c2',
'c/sub': 'another/c/sub'
}
}
});
go(['a', 'b', 'c', 'a/sub/one'],
function(a, b, c, one) {
doh.register(
'mapConfigStar',
[
function mapConfigStar(t){
t.is('c1', a.c.name);
t.is('c1/sub', a.csub.name);
t.is('c2', one.c.name);
t.is('another/c/sub', one.csub.name);
t.is('another/c/dim', one.csub.dimName);
t.is('another/c', b.c.name);
t.is('another/minor', b.c.minorName);
t.is('another/c/sub', b.csub.name);
t.is('another/c', c.name);
t.is('another/minor', c.minorName);
}
]
);
doh.run();
}
);
13 changes: 13 additions & 0 deletions tests/mapConfig/mapConfigStar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>Map Config Star Test</title>
<script type="text/javascript" src="../bootstrap.js"></script>
<script type="text/javascript" src="mapConfigStar-tests.js"></script>
</head>
<body>
<h1>Map Config Star Test</h1>
<p>Test using '*' in the map config.</p>
<p>Check console for messages</p>
</body>
</html>
30 changes: 30 additions & 0 deletions tests/mapConfig/mapConfigStarAdapter-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*global doh */
config({
baseUrl: './',
map: {
'*': {
'd': 'adapter/d'
},
'adapter/d': {
d: 'd'
}
}
});
go(['e', 'adapter/d'],
function(e, adapterD) {
'use strict';
doh.register(
'mapConfigStarAdapter',
[
function mapConfigStarAdapter(t){
t.is('e', e.name);
t.is('d', e.d.name);
t.is(true, e.d.adapted);
t.is(true, adapterD.adapted);
t.is('d', adapterD.name);
}
]
);
doh.run();
}
);
16 changes: 16 additions & 0 deletions tests/mapConfig/mapConfigStarAdapter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Map Config Star Swap Test</title>
<script type="text/javascript" src="../bootstrap.js"></script>
<script type="text/javascript" src="mapConfigStarAdapter-tests.js"></script>
</head>
<body>
<h1>Map Config Star Swap Test</h1>
<p>Test using '*' in the map config, but with an adapter module
that is used to load the non-* version and add to it. More info:
<a href="https://github.com/jrburke/requirejs/issues/277">#277</a></p>

<p>Check console for messages</p>
</body>
</html>
10 changes: 8 additions & 2 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
'namedWrapped',
'require',
'plugins',
'pluginDynamic'
'pluginDynamic',
'mapConfig'
],
i, levels, name;

Expand Down Expand Up @@ -54,8 +55,13 @@
pluginDynamic: function () {
reg('plugins/dynamic');
reg('plugins/dynamicToString');
}
},

mapConfig: function () {
reg('mapConfig/mapConfig');
reg('mapConfig/mapConfigStar');
reg('mapConfig/mapConfigStarAdapter');
}

//basic: true, //include require, exports, module tests.
//anonymous: true, //include function callback and basic object callback,
Expand Down