Permalink
Browse files

Adding mapConfigPlugin test from requirejs

  • Loading branch information...
jrburke committed Oct 3, 2012
1 parent d4c8845 commit cdd50bd94704aaa7f86448f571a09cdf04ae27ad
Showing with 107 additions and 0 deletions.
  1. +1 −0 tests/all.js
  2. +15 −0 tests/mapConfig/mapConfigPlugin.html
  3. +91 −0 tests/mapConfig/mapConfigPlugin.js
View
@@ -5,6 +5,7 @@ doh.registerUrl("mapConfig", "../mapConfig/mapConfig.html");
doh.registerUrl("mapConfigStar", "../mapConfig/mapConfigStar.html");
doh.registerUrl("mapConfigStarAdapter", "../mapConfig/mapConfigStarAdapter.html");
doh.registerUrl("mapConfigSpecificity", "../mapConfig/mapConfigSpecificity.html");
+doh.registerUrl("mapConfigPlugin", "../mapConfig/mapConfigPlugin.html");
doh.registerUrl("plugins", "../plugins/plugins.html");
doh.registerUrl("orderPlugin", "../plugins/order/order.html");
doh.registerUrl("text", "../plugins/text.html");
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>almond: Map Config Plugin Built Test</title>
+ <script type="text/javascript" src="../doh/runner.js"></script>
+ <script type="text/javascript" src="../doh/_browserRunner.js"></script>
+ <script src="../../almond.js"></script>
+ <script type="text/javascript" src="mapConfigPlugin.js"></script>
+</head>
+<body>
+ <h1>almond: Map Config Plugin Built Test</h1>
+ <p>Test using the map config with plugin value after a build.</p>
+ <p>Check console for messages</p>
+</body>
+</html>
@@ -0,0 +1,91 @@
+
+define('plug',{
+ load: function (name, require, load, config) {
+ if (!name) {
+ name = 'main';
+ } else if (name.charAt(0) === '/') {
+ name = 'main' + name;
+ }
+
+ //Only grab the first segment of the name.
+ //This is just to be different, nothing
+ //that is required behavior.
+ name = name.split('/').shift();
+
+ name = 'plug/' + name;
+
+ require([name], load);
+ }
+});
+define('plug/c1',{
+ name: 'plug!c1'
+});
+
+define('a',['c', 'c/sub'], function (c, csub) {
+ return {
+ c: c,
+ csub: csub
+ };
+});
+
+define('plug/main',{
+ name: 'plug!main'
+});
+
+define('b',['c', 'c/sub'], function (c, csub) {
+ return {
+ c: c,
+ csub: csub
+ };
+});
+
+define('plug/c2',{
+ name: 'plug!c2'
+});
+
+define('a/sub/one',['c', 'c/sub'], function (c, csub) {
+ return {
+ c: c,
+ csub: csub
+ };
+});
+
+require({
+ baseUrl: './',
+ paths: {
+ a: 'a1'
+ },
+
+ map: {
+ '*': {
+ c: 'plug!'
+ },
+ 'a': {
+ c: 'plug!c1'
+ },
+ 'a/sub/one': {
+ 'c': 'plug!c2'
+ }
+ }
+ },
+ ['a', 'b', 'c', 'a/sub/one'],
+ function(a, b, c, one) {
+ doh.register(
+ 'mapConfigPlugin',
+ [
+ function mapConfigPlugin(t){
+ t.is('plug!c1', a.c.name);
+ t.is('plug!c1', a.csub.name);
+ t.is('plug!c2', one.c.name);
+ t.is('plug!c2', one.csub.name);
+ t.is('plug!main', b.c.name);
+ t.is('plug!main', b.csub.name);
+ t.is('plug!main', c.name);
+ }
+ ]
+ );
+ doh.run();
+ }
+);
+
+define("mapConfigPlugin-tests", function(){});

0 comments on commit cdd50bd

Please sign in to comment.