Permalink
Browse files

Migrate from expect to assert.expect

After we upgraded to QUnit 1.23.1, we gained support for
assert.expect(). This allows us to guard against any race conditions
within tests, because now expect() will be linked to the specific test
instead of the current running test.
  • Loading branch information...
1 parent 2805fa7 commit a74547aaa76d406dd0b8a441d0a84dc9694a2829 @kevin-brown kevin-brown committed May 24, 2016
View
@@ -9,7 +9,6 @@
"console": false,
"define": false,
"document": false,
- "expect": false,
"MockContainer": false,
"module": false,
"QUnit": false,
@@ -93,7 +93,7 @@ test('options can be unselected individually', function (assert) {
});
test('default values can be set', function (assert) {
- expect(4);
+ assert.expect(4);
var options = new Options({
data: [
@@ -128,7 +128,7 @@ test('default values can be set', function (assert) {
});
test('no default value', function (assert) {
- expect(2);
+ assert.expect(2);
var options = new Options({
data: [
@@ -1,7 +1,7 @@
module('Data adaptor - Tokenizer');
test('triggers the select event', function (assert) {
- expect(2);
+ assert.expect(2);
var SelectData = require('select2/data/select');
var Tokenizer = require('select2/data/tokenizer');
@@ -43,7 +43,7 @@ test('triggers the select event', function (assert) {
});
test('createTag can return null', function (assert) {
- expect(3);
+ assert.expect(3);
var SelectData = require('select2/data/select');
var Tokenizer = require('select2/data/tokenizer');
@@ -92,7 +92,7 @@ test('createTag can return null', function (assert) {
});
test('createTag returning null does not cut the term', function (assert) {
- expect(4);
+ assert.expect(4);
var SelectData = require('select2/data/select');
var Tokenizer = require('select2/data/tokenizer');
@@ -171,7 +171,7 @@ test('createTag returning null does not cut the term', function (assert) {
});
test('works with multiple tokens given', function (assert) {
- expect(4);
+ assert.expect(4);
var SelectData = require('select2/data/select');
var Tokenizer = require('select2/data/tokenizer');
@@ -1,7 +1,7 @@
module('Dropdown - attachBody - positioning');
test('appends to the dropdown parent', function (assert) {
- expect(4);
+ assert.expect(4);
var $ = require('jquery');
@@ -17,7 +17,7 @@ var options = new Options({
});
test('will not trigger if no results were given', function (assert) {
- expect(0);
+ assert.expect(0);
var $element = $('<select></select>');
var select = new ModifiedResults($element, options, new SelectData($element));
@@ -35,7 +35,7 @@ test('will not trigger if no results were given', function (assert) {
});
test('will not trigger if the results list is empty', function (assert) {
- expect(1);
+ assert.expect(1);
var $element = $('<select></select>');
var select = new ModifiedResults($element, options, new SelectData($element));
@@ -63,7 +63,7 @@ test('will not trigger if the results list is empty', function (assert) {
});
test('will not trigger if no results here highlighted', function (assert) {
- expect(2);
+ assert.expect(2);
var $element = $('<select></select>');
var select = new ModifiedResults($element, options, new SelectData($element));
@@ -102,7 +102,7 @@ test('will not trigger if no results here highlighted', function (assert) {
});
test('will trigger if there is a highlighted result', function (assert) {
- expect(2);
+ assert.expect(2);
var $element = $('<select></select>');
var select = new ModifiedResults($element, options, new SelectData($element));
@@ -12,7 +12,7 @@ var CustomDropdown = Utils.Decorate(Dropdown, StopPropagation);
var options = new Options();
test('click event does not propagate', function (assert) {
- expect(1);
+ assert.expect(1);
var $container = $('#qunit-fixture .event-container');
var container = new MockContainer();
@@ -4,7 +4,7 @@ var $ = require('jquery');
var Options = require('select2/options');
test('converted into dataAdapter.current', function (assert) {
- expect(5);
+ assert.expect(5);
var $test = $('<select></select>');
var called = false;
@@ -51,7 +51,7 @@ test('converted into dataAdapter.current', function (assert) {
});
test('single option converted to array automatically', function (assert) {
- expect(2);
+ assert.expect(2);
var $test = $('<select></select>');
var called = false;
@@ -81,7 +81,7 @@ test('single option converted to array automatically', function (assert) {
});
test('only called once', function (assert) {
- expect(8);
+ assert.expect(8);
var $test = $('<select><option value="3" selected>4</option></select>');
var called = 0;
@@ -160,7 +160,7 @@ test('only called once', function (assert) {
module('Options - Deprecated - query');
test('converted into dataAdapter.query automatically', function (assert) {
- expect(6);
+ assert.expect(6);
var $test = $('<select></select>');
var called = false;
@@ -1,7 +1,7 @@
module('Results - highlighting results');
test('results:all with no data skips results:focus', function (assert) {
- expect(0);
+ assert.expect(0);
var $ = require('jquery');
@@ -43,7 +43,7 @@ test('results:all with no data skips results:focus', function (assert) {
});
test('results:all triggers results:focus on the first item', function (assert) {
- expect(2);
+ assert.expect(2);
var $ = require('jquery');
@@ -91,7 +91,7 @@ test('results:all triggers results:focus on the first item', function (assert) {
});
test('results:append does not trigger results:focus', function (assert) {
- expect(0);
+ assert.expect(0);
var $ = require('jquery');
@@ -109,7 +109,7 @@ test('clicking clear will set the placeholder value', function (assert) {
});
test('clicking clear will trigger the unselect event', function (assert) {
- expect(3);
+ assert.expect(3);
var $element = $('#qunit-fixture .single-with-placeholder');
@@ -10,7 +10,7 @@ var Utils = require('select2/utils');
var options = new Options({});
test('backspace will remove a choice', function (assert) {
- expect(3);
+ assert.expect(3);
var KEYS = require('select2/keys');
@@ -52,7 +52,7 @@ test('backspace will remove a choice', function (assert) {
});
test('backspace will set the search text', function (assert) {
- expect(3);
+ assert.expect(3);
var KEYS = require('select2/keys');
@@ -94,7 +94,7 @@ test('updating selection does not shift the focus', function (assert) {
// Check for IE 8, which triggers a false negative during testing
if (window.attachEvent && !window.addEventListener) {
// We must expect 0 assertions or the test will fail
- expect(0);
+ assert.expect(0);
return;
}
@@ -142,7 +142,7 @@ test('the focus event shifts the focus', function (assert) {
// Check for IE 8, which triggers a false negative during testing
if (window.attachEvent && !window.addEventListener) {
// We must expect 0 assertions or the test will fail
- expect(0);
+ assert.expect(0);
return;
}
@@ -12,7 +12,7 @@ var CutomSelection = Utils.Decorate(SingleSelection, StopPropagation);
var options = new Options();
test('click event does not propagate', function (assert) {
- expect(1);
+ assert.expect(1);
var $container = $('#qunit-fixture .event-container');
var container = new MockContainer();

0 comments on commit a74547a

Please sign in to comment.