~ubuntu-branches/ubuntu/quantal/maas/quantal-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/tests/yui/tests/core-tests.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
YUI.add('core-tests', function(Y) {
2
 
 
3
 
    /* {{{ Core URL Tests */
4
 
        var core_urls = {
5
 
            'http://localhost/build/yui/yui.js': { path: 'http://localhost/build/', filter: undefined },
6
 
            'http://localhost/build/yui/yui-debug.js': { path: 'http://localhost/build/', filter: 'debug' },
7
 
            'http://localhost/build/yui-base/yui-base.js': { path: 'http://localhost/build/', filter: undefined },
8
 
            'http://localhost/build/yui-base/yui-base-debug.js': { path: 'http://localhost/build/', filter: 'debug' },
9
 
            'http://localhost/build/yui-rls/yui-rls.js': { path: 'http://localhost/build/', filter: undefined },
10
 
            'http://localhost/build/yui-rls/yui-rls-debug.js': { path: 'http://localhost/build/', filter: 'debug' },
11
 
            'http://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base.js': { path: 'http://combohost.com/combo?/build/', filter: undefined },
12
 
            'http://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base-debug.js': { path: 'http://combohost.com/combo?/build/', filter: 'debug' },
13
 
            'http://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base.js&build/loader/loader.js': { path: 'http://combohost.com/combo?/build/', filter: undefined },
14
 
            'http://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base-debug.js&buid/loader/loader.js': { path: 'http://combohost.com/combo?/build/', filter: 'debug' },
15
 
            'https://localhost/build/yui/yui.js': { path: 'https://localhost/build/', filter: undefined },
16
 
            'https://localhost/build/yui/yui-debug.js': { path: 'https://localhost/build/', filter: 'debug' },
17
 
            'https://localhost/build/yui-base/yui-base.js': { path: 'https://localhost/build/', filter: undefined },
18
 
            'https://localhost/build/yui-base/yui-base-debug.js': { path: 'https://localhost/build/', filter: 'debug' },
19
 
            'https://localhost/build/yui-rls/yui-rls.js': { path: 'https://localhost/build/', filter: undefined },
20
 
            'https://localhost/build/yui-rls/yui-rls-debug.js': { path: 'https://localhost/build/', filter: 'debug' },
21
 
            'https://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base.js': { path: 'https://combohost.com/combo?/build/', filter: undefined },
22
 
            'https://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base-debug.js': { path: 'https://combohost.com/combo?/build/', filter: 'debug' },
23
 
            'https://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base.js&build/loader/loader.js': { path: 'https://combohost.com/combo?/build/', filter: undefined },
24
 
            'https://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base-debug.js&buid/loader/loader.js': { path: 'https://combohost.com/combo?/build/', filter: 'debug' },
25
 
 
26
 
            '/build/yui/yui.js': { path: '/build/', filter: undefined },
27
 
            '/build/yui/yui-debug.js': { path: '/build/', filter: 'debug' },
28
 
            '/build/yui-base/yui-base.js': { path: '/build/', filter: undefined },
29
 
            '/build/yui-base/yui-base-debug.js': { path: '/build/', filter: 'debug' },
30
 
            '/build/yui-rls/yui-rls.js': { path: '/build/', filter: undefined },
31
 
            '/build/yui-rls/yui-rls-debug.js': { path: '/build/', filter: 'debug' },
32
 
            'build/simpleyui/simpleyui.js': { path: 'build/', filter: undefined },
33
 
            'build/simpleyui/simpleyui-debug.js': { path: 'build/', filter: 'debug' },
34
 
            'build/yui/yui.js': { path: 'build/', filter: undefined },
35
 
            'build/yui/yui-debug.js': { path: 'build/', filter: 'debug' },
36
 
            'build/yui-rls/yui-rls.js': { path: 'build/', filter: undefined },
37
 
            'build/yui-rls/yui-rls-debug.js': { path: 'build/', filter: 'debug' },
38
 
            '//combohost.com/combo?foo/foo.js&bar-bar.js&/build/simpleyui/simpleyui.js&build/loader/loader.js': { path: '//combohost.com/combo?/build/', filter: undefined },
39
 
            '//combohost.com/combo?foo/foo.js&bar-bar.js&/build/simpleyui/simpleyui-debug.js&buid/oop/oop.js': { path: '//combohost.com/combo?/build/', filter: 'debug' },
40
 
            '//combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base.js': { path: '//combohost.com/combo?/build/', filter: undefined },
41
 
            '//combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base-debug.js': { path: '//combohost.com/combo?/build/', filter: 'debug' }
42
 
        };
43
 
    /* }}} */
44
 
 
45
 
    var testCore = new Y.Test.Case({
46
 
 
47
 
        name: "Core tests",
48
 
 
49
 
        'cached functions should execute only once per input': function() {
50
 
 
51
 
            var r1 = "", r2 = "", r3 = "";
52
 
 
53
 
            var f1 = function(a) {
54
 
                r1 += a;
55
 
            };
56
 
            var c1 = Y.cached(f1);
57
 
 
58
 
            c1('a');
59
 
            c1('b');
60
 
            c1('a');
61
 
            c1('b');
62
 
            c1('a');
63
 
            c1('b');
64
 
 
65
 
            Y.Assert.areEqual('ab', r1);
66
 
 
67
 
            var f2 = function(a, b) {
68
 
                r2 += (a + b);
69
 
            };
70
 
            var c2 = Y.cached(f2);
71
 
 
72
 
            c2('a', 'b');
73
 
            c2('c', 'd');
74
 
            c2('a', 'b');
75
 
            c2('c', 'd');
76
 
            c2('a', 'b');
77
 
            c2('c', 'd');
78
 
 
79
 
            var o = new Y.EventTarget();
80
 
            o.foo = 1;
81
 
 
82
 
            var f3 = function(a) {
83
 
                Y.Assert.areEqual(1, this.foo);
84
 
                r3 += a;
85
 
            };
86
 
 
87
 
            var c3 = Y.cached(Y.bind(f3, o), {
88
 
                a: 'z'
89
 
            });
90
 
 
91
 
            c3('a');
92
 
            c3('b');
93
 
            c3('a');
94
 
            c3('b');
95
 
            c3('a');
96
 
            c3('b');
97
 
 
98
 
            Y.Assert.areEqual('b', r3);
99
 
 
100
 
            // falsy second arg needs to produce a different key than no second arg
101
 
            var cn = Y.ClassNameManager.getClassName;
102
 
            Y.Assert.areEqual('yui3-a-', cn('a', ''));
103
 
            Y.Assert.areEqual('yui3-a', cn('a'));
104
 
 
105
 
        },
106
 
 
107
 
        test_cached_undefined_null: function() {
108
 
            
109
 
            var f1 = function(a) {
110
 
                return a;
111
 
            };
112
 
            var c1 = Y.cached(f1);
113
 
 
114
 
            var a = c1(null);
115
 
            Y.Assert.areEqual(a, null);
116
 
            a = c1(undefined);
117
 
            Y.Assert.areEqual(a, undefined);
118
 
            a = c1('foo');
119
 
            Y.Assert.areEqual(a, 'foo');
120
 
            
121
 
        },
122
 
 
123
 
        test_ie_enum_bug: function() {
124
 
            var o = {
125
 
                valueOf: function() {
126
 
                    return 'foo';
127
 
                }
128
 
            },
129
 
 
130
 
            p = Y.merge(o);
131
 
            Y.Assert.areEqual('foo', p.valueOf());
132
 
        },
133
 
        test_guid: function() {
134
 
            var id, id2, i;
135
 
            for (i = 0; i < 1000; i++) {           
136
 
                id = Y.guid();
137
 
                id2 = Y.guid();
138
 
                Y.Assert.areNotEqual(id, id2, 'GUID creation failed, ids match');
139
 
            }
140
 
        },
141
 
        test_stamp: function() {
142
 
            var id, id2, i;
143
 
            for (i = 0; i < 1000; i++) {           
144
 
                id = Y.stamp({});
145
 
                id2 = Y.stamp({});
146
 
                Y.Assert.areNotEqual(id, id2, 'STAMP GUID creation failed, ids match');
147
 
            }
148
 
        },
149
 
        test_use_array: function() {
150
 
            var Assert = Y.Assert;
151
 
            YUI().use(['dd', 'node'], function(Y) {
152
 
                Assert.isObject(Y.DD, 'DD was not loaded');
153
 
                Assert.isObject(Y.Node, 'Node was not loaded');
154
 
            });
155
 
        },
156
 
        test_use_strings: function() {
157
 
            var Assert = Y.Assert;
158
 
            YUI().use('dd', 'node', function(Y) {
159
 
                Assert.isObject(Y.DD, 'DD was not loaded');
160
 
                Assert.isObject(Y.Node, 'Node was not loaded');
161
 
            });
162
 
        },
163
 
        test_one_submodule: function() {
164
 
            var Assert = Y.Assert;
165
 
            YUI({
166
 
                  modules:{
167
 
                      'something':{
168
 
                          'submodules':{
169
 
                              'something1':{
170
 
                                    fullpath: './assets/sub.js'
171
 
                              }
172
 
                          }
173
 
                      }
174
 
                  }
175
 
            }).use('something1', function(Y) {
176
 
                Assert.isTrue(Y.something1);
177
 
            });
178
 
        },
179
 
        test_rollup_false: function() {
180
 
            var Assert = Y.Assert;
181
 
            YUI().use('dd', function(Y) {
182
 
                Assert.isUndefined(Y.Env._attached.dd, 'DD Alias Module was attached');
183
 
            });
184
 
            YUI().use('node', function(Y) {
185
 
                Assert.isUndefined(Y.Env._attached.node, 'Node Alias Module was attached');
186
 
            });
187
 
        },
188
 
        test_base_path: function() {
189
 
            var Assert = Y.Assert;
190
 
            for (var i in core_urls) {
191
 
                var info = Y.Env.parseBasePath(i, Y.Env._BASE_RE);
192
 
                Assert.areSame(info.path, core_urls[i].path, 'Paths do not match (' + core_urls[i].path + ')');
193
 
                //This test is assuming that IE returns an undefined, but it actually returns an empty string for the property
194
 
                //Assert.areSame(info.filter, core_urls[i].filter, 'Filters do not match (' + core_urls[i].path + ')');
195
 
            }
196
 
        },
197
 
        test_log_params: function() {
198
 
            if (typeof console == "undefined" || !console.info) {
199
 
                return;
200
 
            }
201
 
            var l = console.info,
202
 
                Assert = Y.Assert,
203
 
                last;
204
 
 
205
 
            console.info = function(str) {
206
 
                last = str.split(':')[0];
207
 
            };
208
 
 
209
 
            YUI().use(function (Y) {
210
 
              Y.config.logInclude = {
211
 
                  logMe: true,
212
 
                  butNotMe: false
213
 
              };
214
 
              
215
 
              Y.log('test logInclude logMe','info','logMe');
216
 
              Assert.areEqual(last, 'logMe', 'logInclude (true) Failed');
217
 
              last = undefined;
218
 
 
219
 
              Y.log('test logInclude butNotMe','info','butNotMe');
220
 
              Assert.isUndefined(last, 'logInclude (false) Failed');
221
 
 
222
 
              Y.config.logInclude = '';
223
 
              Y.config.logExclude = {
224
 
                  excludeMe: true,
225
 
                  butDontExcludeMe: false
226
 
              };
227
 
              Y.log('test logExclude excludeMe','info','excludeMe');
228
 
              Assert.isUndefined(last, 'excludeInclude (true) Failed');
229
 
              Y.log('test logExclude butDontExcludeMe','info','butDontExcludeMe');
230
 
              Assert.areEqual(last, 'butDontExcludeMe', 'logExclue (false) Failed');
231
 
 
232
 
            });
233
 
            console.info = l;
234
 
        },
235
 
        test_loader_combo_sep: function() {
236
 
            var Assert = Y.Assert;
237
 
            
238
 
            var testY = YUI({
239
 
                debug: true,
240
 
                combine: true,
241
 
                comboSep: '--;;--'
242
 
            });
243
 
            var loader = new testY.Loader(testY.config);
244
 
            testY.Env._loader = loader;
245
 
 
246
 
            testY.Get.script = function(s) {
247
 
                var url = s[0];
248
 
                Assert.isTrue((url.indexOf(testY.config.comboSep) > 5), 'Combo seperator (' + testY.config.comboSep + ') was not used');
249
 
                testY._loading = false;
250
 
            };
251
 
            testY.use('editor');
252
 
        },
253
 
        test_multiple_ua: function() {
254
 
            var Assert = Y.Assert,
255
 
                globalUA = YUI.Env.UA,
256
 
                uaFF = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0) Gecko/20100101 Firefox/6.0',
257
 
                uaChrome = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.860.0 Safari/535.2';
258
 
    
259
 
            var Y1 = YUI();
260
 
            Assert.areEqual(globalUA.userAgent, Y1.UA.userAgent, 'Global UA and local (Y1) UA are different');
261
 
 
262
 
            var parsed = YUI.Env.parseUA(uaChrome);
263
 
            Assert.areEqual(parsed.userAgent, uaChrome, 'Parsed UA not equal Chrome');
264
 
            Assert.isTrue((parsed.chrome > 0), 'Parsed UA not equal Chrome');
265
 
 
266
 
            var Y2 = YUI();
267
 
            Assert.areEqual(globalUA.userAgent, Y2.UA.userAgent, 'Global UA and local (Y2) UA are different');
268
 
 
269
 
 
270
 
            Assert.areEqual(YUI.Env.UA.userAgent, Y2.UA.userAgent, 'Global UA and local (Y2) UA are different');
271
 
 
272
 
        }
273
 
    });
274
 
 
275
 
    Y.SeedTests.add(testCore);
276
 
});