1 | <!DOCTYPE html> |
---|
2 | <html lang="en"> |
---|
3 | <head> |
---|
4 | <meta charset="utf-8"> |
---|
5 | <title>Dojo loader mapping after build test</title> |
---|
6 | </head> |
---|
7 | <body> |
---|
8 | <script> |
---|
9 | var dojoConfig = { |
---|
10 | async: true, |
---|
11 | map: { |
---|
12 | 'my/replacement/A': { |
---|
13 | 'my/A': 'my/A' |
---|
14 | }, |
---|
15 | '*': { |
---|
16 | 'my/A': 'my/replacement/A' |
---|
17 | } |
---|
18 | } |
---|
19 | }; |
---|
20 | </script> |
---|
21 | <script src="../../../dojo.js"></script> |
---|
22 | <script> |
---|
23 | // simulate a built layer, this is added to dojo.js by the builder |
---|
24 | require({ |
---|
25 | cache: { |
---|
26 | 'my/replacement/A': function () { |
---|
27 | define([ '../A' ], function (A) { |
---|
28 | return { it: 'is a replacement module' }; |
---|
29 | }); |
---|
30 | }, |
---|
31 | 'my/A': function () { |
---|
32 | define([ './B' ], function (B) { |
---|
33 | return { it: 'is the original module' }; |
---|
34 | }); |
---|
35 | }, |
---|
36 | 'my/B': function () { |
---|
37 | define([], function () { |
---|
38 | return { it: 'is a module dependency' }; |
---|
39 | }); |
---|
40 | } |
---|
41 | } |
---|
42 | }); |
---|
43 | // consume pending cache, the following are added at the end of a built dojo.js in a closure |
---|
44 | require({ cache: {} }); |
---|
45 | !require.async && require(['dojo']); |
---|
46 | require.boot && require.apply(null, require.boot); |
---|
47 | |
---|
48 | require([ 'doh' ], function (doh) { |
---|
49 | // begin test: |
---|
50 | // moving modules from the pending cache to the module cache should ignore |
---|
51 | // any mapping, pathing, or alias rules |
---|
52 | |
---|
53 | doh.register('star-mapping', [ |
---|
54 | { |
---|
55 | name: 'mapping after build', |
---|
56 | runTest: function (t) { |
---|
57 | var def = new doh.Deferred(); |
---|
58 | |
---|
59 | t.requireHandle = require.on('error', function (e) { |
---|
60 | def.errback(e); |
---|
61 | }); |
---|
62 | require(['my/A'], def.getTestCallback(function (A) { |
---|
63 | t.is('is a replacement module', A.it, 'A should be a replacement module'); |
---|
64 | })); |
---|
65 | |
---|
66 | return def; |
---|
67 | }, |
---|
68 | tearDown: function (t) { |
---|
69 | t.requireHandle.remove(); |
---|
70 | } |
---|
71 | } |
---|
72 | ]); |
---|
73 | doh.runOnLoad(); |
---|
74 | }); |
---|
75 | </script> |
---|
76 | </body> |
---|
77 | </html> |
---|