1
- define ( [
1
+ define ( [
2
+ "qunit" ,
2
3
"jquery"
3
- ] , function ( $ ) {
4
+ ] , function ( QUnit , $ ) {
4
5
5
6
var exports = { } ;
6
7
7
8
function testWidgetDefaults ( widget , defaults ) {
8
9
var pluginDefaults = $ . ui [ widget ] . prototype . options ;
9
10
10
11
// Ensure that all defaults have the correct value
11
- test ( "defined defaults" , function ( ) {
12
+ QUnit . test ( "defined defaults" , function ( assert ) {
12
13
var count = 0 ;
13
14
$ . each ( defaults , function ( key , val ) {
14
- expect ( ++ count ) ;
15
+ assert . expect ( ++ count ) ;
15
16
if ( $ . isFunction ( val ) ) {
16
- ok ( $ . isFunction ( pluginDefaults [ key ] ) , key ) ;
17
+ assert . ok ( $ . isFunction ( pluginDefaults [ key ] ) , key ) ;
17
18
return ;
18
19
}
19
- deepEqual ( pluginDefaults [ key ] , val , key ) ;
20
+ assert . deepEqual ( pluginDefaults [ key ] , val , key ) ;
20
21
} ) ;
21
22
} ) ;
22
23
23
24
// Ensure that all defaults were tested
24
- test ( "tested defaults" , function ( ) {
25
+ QUnit . test ( "tested defaults" , function ( assert ) {
25
26
var count = 0 ;
26
27
$ . each ( pluginDefaults , function ( key ) {
27
- expect ( ++ count ) ;
28
- ok ( key in defaults , key ) ;
28
+ assert . expect ( ++ count ) ;
29
+ assert . ok ( key in defaults , key ) ;
29
30
} ) ;
30
31
} ) ;
31
32
}
32
33
33
34
function testWidgetOverrides ( widget ) {
34
35
if ( $ . uiBackCompat === false ) {
35
- test ( "$.widget overrides" , function ( ) {
36
- expect ( 4 ) ;
36
+ QUnit . test ( "$.widget overrides" , function ( assert ) {
37
+ assert . expect ( 4 ) ;
37
38
$ . each ( [
38
39
"_createWidget" ,
39
40
"destroy" ,
40
41
"option" ,
41
42
"_trigger"
42
43
] , function ( i , method ) {
43
- strictEqual ( $ . ui [ widget ] . prototype [ method ] ,
44
+ assert . strictEqual ( $ . ui [ widget ] . prototype [ method ] ,
44
45
$ . Widget . prototype [ method ] , "should not override " + method ) ;
45
46
} ) ;
46
47
} ) ;
47
48
}
48
49
}
49
50
50
51
function testBasicUsage ( widget ) {
51
- test ( "basic usage" , function ( ) {
52
- expect ( 3 ) ;
52
+ QUnit . test ( "basic usage" , function ( assert ) {
53
+ assert . expect ( 3 ) ;
53
54
54
55
var defaultElement = $ . ui [ widget ] . prototype . defaultElement ;
55
56
$ ( defaultElement ) . appendTo ( "body" ) [ widget ] ( ) . remove ( ) ;
56
- ok ( true , "initialized on element" ) ;
57
+ assert . ok ( true , "initialized on element" ) ;
57
58
58
59
$ ( defaultElement ) [ widget ] ( ) . remove ( ) ;
59
- ok ( true , "initialized on disconnected DOMElement - never connected" ) ;
60
+ assert . ok ( true , "initialized on disconnected DOMElement - never connected" ) ;
60
61
61
62
// Ensure manipulating removed elements works (#3664)
62
63
$ ( defaultElement ) . appendTo ( "body" ) . remove ( ) [ widget ] ( ) . remove ( ) ;
63
- ok ( true , "initialized on disconnected DOMElement - removed" ) ;
64
+ assert . ok ( true , "initialized on disconnected DOMElement - removed" ) ;
64
65
} ) ;
65
66
}
66
67
67
68
exports . testWidget = function ( widget , settings ) {
68
- module ( widget + ": common widget" ) ;
69
+ QUnit . module ( widget + ": common widget" ) ;
69
70
70
71
exports . testJshint ( widget ) ;
71
72
testWidgetDefaults ( widget , settings . defaults ) ;
72
73
testWidgetOverrides ( widget ) ;
73
74
testBasicUsage ( widget ) ;
74
- test ( "version" , function ( ) {
75
- expect ( 1 ) ;
76
- ok ( "version" in $ . ui [ widget ] . prototype , "version property exists" ) ;
75
+ QUnit . test ( "version" , function ( assert ) {
76
+ assert . expect ( 1 ) ;
77
+ assert . ok ( "version" in $ . ui [ widget ] . prototype , "version property exists" ) ;
77
78
} ) ;
78
79
} ;
79
80
@@ -85,9 +86,9 @@ exports.testJshint = function( module ) {
85
86
return ;
86
87
}
87
88
88
- asyncTest ( "JSHint" , function ( ) {
89
+ QUnit . asyncTest ( "JSHint" , function ( assert ) {
89
90
require ( [ "jshint" ] , function ( ) {
90
- expect ( 1 ) ;
91
+ assert . expect ( 1 ) ;
91
92
92
93
$ . when (
93
94
$ . ajax ( {
@@ -117,12 +118,12 @@ exports.testJshint = function( module ) {
117
118
return "[L" + error . line + ":C" + error . character + "] " +
118
119
error . reason + "\n" + error . evidence + "\n" ;
119
120
} ) . join ( "\n" ) ;
120
- ok ( passed , errors ) ;
121
- start ( ) ;
121
+ assert . ok ( passed , errors ) ;
122
+ QUnit . start ( ) ;
122
123
} )
123
124
. fail ( function ( hintError , srcError ) {
124
- ok ( false , "error loading source: " + ( hintError || srcError ) . statusText ) ;
125
- start ( ) ;
125
+ assert . ok ( false , "error loading source: " + ( hintError || srcError ) . statusText ) ;
126
+ QUnit . start ( ) ;
126
127
} ) ;
127
128
} ) ;
128
129
} ) ;
0 commit comments