11define ( [
2- "jquery"
3- ] , function ( $ ) {
2+ "qunit" ,
3+ "jquery" ] ,
4+ function ( QUnit , $ ) {
45
56var exports = { } ;
67
78function testWidgetDefaults ( widget , defaults ) {
89 var pluginDefaults = $ . ui [ widget ] . prototype . options ;
910
1011 // Ensure that all defaults have the correct value
11- test ( "defined defaults" , function ( ) {
12+ QUnit . test ( "defined defaults" , function ( assert ) {
1213 var count = 0 ;
1314 $ . each ( defaults , function ( key , val ) {
14- expect ( ++ count ) ;
15+ assert . expect ( ++ count ) ;
1516 if ( $ . isFunction ( val ) ) {
16- ok ( $ . isFunction ( pluginDefaults [ key ] ) , key ) ;
17+ assert . ok ( $ . isFunction ( pluginDefaults [ key ] ) , key ) ;
1718 return ;
1819 }
19- deepEqual ( pluginDefaults [ key ] , val , key ) ;
20+ assert . deepEqual ( pluginDefaults [ key ] , val , key ) ;
2021 } ) ;
2122 } ) ;
2223
2324 // Ensure that all defaults were tested
24- test ( "tested defaults" , function ( ) {
25+ QUnit . test ( "tested defaults" , function ( assert ) {
2526 var count = 0 ;
2627 $ . each ( pluginDefaults , function ( key ) {
27- expect ( ++ count ) ;
28- ok ( key in defaults , key ) ;
28+ assert . expect ( ++ count ) ;
29+ assert . ok ( key in defaults , key ) ;
2930 } ) ;
3031 } ) ;
3132}
3233
3334function testWidgetOverrides ( widget ) {
3435 if ( $ . uiBackCompat === false ) {
35- test ( "$.widget overrides" , function ( ) {
36- expect ( 4 ) ;
36+ QUnit . test ( "$.widget overrides" , function ( assert ) {
37+ assert . expect ( 4 ) ;
3738 $ . each ( [
3839 "_createWidget" ,
3940 "destroy" ,
4041 "option" ,
4142 "_trigger"
4243 ] , function ( i , method ) {
43- strictEqual ( $ . ui [ widget ] . prototype [ method ] ,
44+ assert . strictEqual ( $ . ui [ widget ] . prototype [ method ] ,
4445 $ . Widget . prototype [ method ] , "should not override " + method ) ;
4546 } ) ;
4647 } ) ;
4748 }
4849}
4950
5051function testBasicUsage ( widget ) {
51- test ( "basic usage" , function ( ) {
52- expect ( 3 ) ;
52+ QUnit . test ( "basic usage" , function ( assert ) {
53+ assert . expect ( 3 ) ;
5354
5455 var defaultElement = $ . ui [ widget ] . prototype . defaultElement ;
5556 $ ( defaultElement ) . appendTo ( "body" ) [ widget ] ( ) . remove ( ) ;
56- ok ( true , "initialized on element" ) ;
57+ assert . ok ( true , "initialized on element" ) ;
5758
5859 $ ( defaultElement ) [ widget ] ( ) . remove ( ) ;
59- ok ( true , "initialized on disconnected DOMElement - never connected" ) ;
60+ assert . ok ( true , "initialized on disconnected DOMElement - never connected" ) ;
6061
6162 // Ensure manipulating removed elements works (#3664)
6263 $ ( defaultElement ) . appendTo ( "body" ) . remove ( ) [ widget ] ( ) . remove ( ) ;
63- ok ( true , "initialized on disconnected DOMElement - removed" ) ;
64+ assert . ok ( true , "initialized on disconnected DOMElement - removed" ) ;
6465 } ) ;
6566}
6667
6768exports . testWidget = function ( widget , settings ) {
68- module ( widget + ": common widget" ) ;
69+ QUnit . module ( widget + ": common widget" ) ;
6970
7071 exports . testJshint ( "/widgets/" + widget ) ;
7172 testWidgetDefaults ( widget , settings . defaults ) ;
7273 testWidgetOverrides ( widget ) ;
7374 if ( ! settings . noDefaultElement ) {
7475 testBasicUsage ( widget ) ;
7576 }
76- test ( "version" , function ( ) {
77- expect ( 1 ) ;
78- ok ( "version" in $ . ui [ widget ] . prototype , "version property exists" ) ;
77+ QUnit . test ( "version" , function ( assert ) {
78+ assert . expect ( 1 ) ;
79+ assert . ok ( "version" in $ . ui [ widget ] . prototype , "version property exists" ) ;
7980 } ) ;
8081} ;
8182
@@ -87,9 +88,10 @@ exports.testJshint = function( module ) {
8788 return ;
8889 }
8990
90- asyncTest ( "JSHint" , function ( ) {
91+ QUnit . test ( "JSHint" , function ( assert ) {
92+ var ready = assert . async ( ) ;
9193 require ( [ "jshint" ] , function ( ) {
92- expect ( 1 ) ;
94+ assert . expect ( 1 ) ;
9395
9496 $ . when (
9597 $ . ajax ( {
@@ -119,12 +121,12 @@ exports.testJshint = function( module ) {
119121 return "[L" + error . line + ":C" + error . character + "] " +
120122 error . reason + "\n" + error . evidence + "\n" ;
121123 } ) . join ( "\n" ) ;
122- ok ( passed , errors ) ;
123- start ( ) ;
124+ assert . ok ( passed , errors ) ;
125+ ready ( ) ;
124126 } )
125127 . fail ( function ( hintError , srcError ) {
126- ok ( false , "error loading source: " + ( hintError || srcError ) . statusText ) ;
127- start ( ) ;
128+ assert . ok ( false , "error loading source: " + ( hintError || srcError ) . statusText ) ;
129+ ready ( ) ;
128130 } ) ;
129131 } ) ;
130132 } ) ;
0 commit comments