Skip to content

Commit f0c8b77

Browse files
committed
Form: Shift form-reset-mixin to use no globals
1 parent 3dd45b1 commit f0c8b77

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

tests/unit/form-reset-mixin/core.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
define( [
2+
"qunit",
23
"jquery",
34
"lib/common",
45
"ui/widget",
56
"ui/form-reset-mixin"
6-
], function( $, common ) {
7+
], function( QUnit, $, common ) {
78

8-
module( "widget factory", {
9-
setup: function() {
9+
QUnit.module( "widget factory", {
10+
beforeEach: function() {
1011
$.widget( "ui.testWidget", [ $.ui.formResetMixin, {
1112
_create: function() {
1213
this._bindFormResetHandler();
@@ -22,35 +23,37 @@ module( "widget factory", {
2223
$.ui.testWidget.refreshed = [];
2324
},
2425

25-
teardown: function() {
26+
afterEach: function() {
2627
delete $.ui.testWidget;
2728
delete $.fn.testWidget;
2829
}
2930
} );
3031

3132
common.testJshint( "form-reset-mixin" );
3233

33-
asyncTest( "form reset", function() {
34-
expect( 2 );
34+
QUnit.test( "form reset", function( assert ) {
35+
var ready = assert.async();
36+
assert.expect( 2 );
3537

3638
var form = $( "#main" );
3739
var inputs = form.find( "input" );
3840

3941
inputs.testWidget();
4042
form.on( "reset", function() {
4143
setTimeout( function() {
42-
deepEqual( $.ui.testWidget.refreshed, [ "input1", "input2", "input3", "input4" ],
44+
assert.deepEqual( $.ui.testWidget.refreshed, [ "input1", "input2", "input3", "input4" ],
4345
"All widgets are refreshed on form reset" );
44-
equal( form.data( "ui-form-reset-instances" ).length, 4,
46+
assert.equal( form.data( "ui-form-reset-instances" ).length, 4,
4547
"All widget instances are tracked against the form" );
46-
start();
48+
ready();
4749
} );
4850
} );
4951
form[ 0 ].reset();
5052
} );
5153

52-
asyncTest( "destroy", function() {
53-
expect( 2 );
54+
QUnit.test( "destroy", function( assert ) {
55+
var ready = assert.async();
56+
assert.expect( 2 );
5457

5558
var form = $( "#main" );
5659
var inputs = form.find( "input" );
@@ -62,18 +65,19 @@ asyncTest( "destroy", function() {
6265

6366
form.on( "reset", function() {
6467
setTimeout( function() {
65-
deepEqual( $.ui.testWidget.refreshed, [ "input1", "input3", "input4" ],
68+
assert.deepEqual( $.ui.testWidget.refreshed, [ "input1", "input3", "input4" ],
6669
"All widgets are refreshed on form reset" );
67-
deepEqual( form.data( "ui-form-reset-instances" ).length, 3,
70+
assert.deepEqual( form.data( "ui-form-reset-instances" ).length, 3,
6871
"All widget instances are tracked against the form" );
69-
start();
72+
ready();
7073
} );
7174
} );
7275
form[ 0 ].reset();
7376
} );
7477

75-
asyncTest( "destroy all", function() {
76-
expect( 2 );
78+
QUnit.test( "destroy all", function( assert ) {
79+
var ready = assert.async();
80+
assert.expect( 2 );
7781

7882
var form = $( "#main" );
7983

@@ -83,10 +87,10 @@ asyncTest( "destroy all", function() {
8387

8488
form.on( "reset", function() {
8589
setTimeout( function() {
86-
deepEqual( $.ui.testWidget.refreshed, [], "No widgets are refreshed after destroy" );
87-
strictEqual( form.data( "ui-form-reset-instances" ), undefined,
90+
assert.deepEqual( $.ui.testWidget.refreshed, [], "No widgets are refreshed after destroy" );
91+
assert.strictEqual( form.data( "ui-form-reset-instances" ), undefined,
8892
"Form data is removed when the last widget instance is destroyed" );
89-
start();
93+
ready();
9094
} );
9195
} );
9296
form[ 0 ].reset();

0 commit comments

Comments
 (0)