Merge "mediawiki.action.edit: Move collapsibleFooter cookies to localStorage"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.inspect.test.js
1 ( function ( mw ) {
2 // Whitespace and serialisation of function bodies
3 // different in browsers.
4 var functionSize = String( function () {} ).length;
5
6 QUnit.module( 'mediawiki.inspect' );
7
8 QUnit.test( '.getModuleSize() - scripts', function ( assert ) {
9 mw.loader.implement(
10 'test.inspect.script',
11 function () { 'example'; }
12 );
13
14 return mw.loader.using( 'test.inspect.script' ).then( function () {
15 assert.equal(
16 mw.inspect.getModuleSize( 'test.inspect.script' ) - functionSize,
17 // name, script function
18 32,
19 'test.inspect.script'
20 );
21 } );
22 } );
23
24 QUnit.test( '.getModuleSize() - scripts, styles', function ( assert ) {
25 mw.loader.implement(
26 'test.inspect.both',
27 function () { 'example'; },
28 { css: [ '.example {}' ] }
29 );
30
31 return mw.loader.using( 'test.inspect.both' ).then( function () {
32 assert.equal(
33 mw.inspect.getModuleSize( 'test.inspect.both' ) - functionSize,
34 // name, script function, styles object
35 54,
36 'test.inspect.both'
37 );
38 } );
39 } );
40
41 QUnit.test( '.getModuleSize() - scripts, messages', function ( assert ) {
42 mw.loader.implement(
43 'test.inspect.scriptmsg',
44 function () { 'example'; },
45 {},
46 { example: 'Hello world.' }
47 );
48
49 return mw.loader.using( 'test.inspect.scriptmsg' ).then( function () {
50 assert.equal(
51 mw.inspect.getModuleSize( 'test.inspect.scriptmsg' ) - functionSize,
52 // name, script function, empty styles object, messages object
53 65,
54 'test.inspect.scriptmsg'
55 );
56 } );
57 } );
58
59 QUnit.test( '.getModuleSize() - scripts, styles, messages, templates', function ( assert ) {
60 mw.loader.implement(
61 'test.inspect.all',
62 function () { 'example'; },
63 { css: [ '.example {}' ] },
64 { example: 'Hello world.' },
65 { 'example.html': '<p>Hello world.<p>' }
66 );
67
68 return mw.loader.using( 'test.inspect.all' ).then( function () {
69 assert.equal(
70 mw.inspect.getModuleSize( 'test.inspect.all' ) - functionSize,
71 // name, script function, styles object, messages object, templates object
72 118,
73 'test.inspect.all'
74 );
75 } );
76 } );
77 }( mediaWiki ) );