@@ -27,14 +27,14 @@ test( "widget creation", function() {
27
27
} ) ;
28
28
29
29
test ( "jQuery usage" , function ( ) {
30
- expect ( 10 ) ;
30
+ expect ( 11 ) ;
31
31
32
- var shouldInit = false ;
32
+ var shouldCreate = false ;
33
33
34
34
$ . widget ( "ui.testWidget" , {
35
35
getterSetterVal : 5 ,
36
36
_create : function ( ) {
37
- ok ( shouldInit , "init called on instantiation" ) ;
37
+ ok ( shouldCreate , "create called on instantiation" ) ;
38
38
} ,
39
39
methodWithParams : function ( param1 , param2 ) {
40
40
ok ( true , "method called via .pluginName(methodName)" ) ;
@@ -54,9 +54,13 @@ test( "jQuery usage", function() {
54
54
}
55
55
} ) ;
56
56
57
- shouldInit = true ;
58
- var elem = $ ( "<div></div>" ) . testWidget ( ) ;
59
- shouldInit = false ;
57
+ shouldCreate = true ;
58
+ var elem = $ ( "<div></div>" )
59
+ . bind ( "testwidgetcreate" , function ( ) {
60
+ ok ( shouldCreate , "create event triggered on instantiation" ) ;
61
+ } )
62
+ . testWidget ( ) ;
63
+ shouldCreate = false ;
60
64
61
65
var instance = elem . data ( "testWidget" ) ;
62
66
equals ( typeof instance , "object" , "instance stored in .data(pluginName)" ) ;
@@ -74,12 +78,12 @@ test( "jQuery usage", function() {
74
78
test ( "direct usage" , function ( ) {
75
79
expect ( 9 ) ;
76
80
77
- var shouldInit = false ;
81
+ var shouldCreate = false ;
78
82
79
83
$ . widget ( "ui.testWidget" , {
80
84
getterSetterVal : 5 ,
81
85
_create : function ( ) {
82
- ok ( shouldInit , "init called on instantiation" ) ;
86
+ ok ( shouldCreate , "create called on instantiation" ) ;
83
87
} ,
84
88
methodWithParams : function ( param1 , param2 ) {
85
89
ok ( true , "method called dirctly" ) ;
@@ -99,9 +103,9 @@ test( "direct usage", function() {
99
103
100
104
var elem = $ ( "<div></div>" ) [ 0 ] ;
101
105
102
- shouldInit = true ;
106
+ shouldCreate = true ;
103
107
var instance = new $ . ui . testWidget ( { } , elem ) ;
104
- shouldInit = false ;
108
+ shouldCreate = false ;
105
109
106
110
equals ( $ ( elem ) . data ( "testWidget" ) , instance ,
107
111
"instance stored in .data(pluginName)" ) ;
0 commit comments