1
0
mirror of synced 2024-11-25 14:26:03 +03:00

Combine tests into a single file

This combines all of the tests into a single HTML file. This reduces
the number of Sauce Labs sessions and should improve test times.
This commit is contained in:
Kevin Brown 2015-03-11 18:51:55 -04:00
parent 30974e2422
commit 4fb079b34f
13 changed files with 156 additions and 328 deletions

View File

@ -1,39 +0,0 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<select class="single" title="This is an example title" tabindex="0">
<option value="default">Default</option>
<option value="1">One</option>
<option>2</option>
</select>
<select class="multiple" multiple="multiple" title="One more example title" tabindex="0">
<option value="default">Default</option>
<option value="1">One</option>
<option>2</option>
</select>
<select class="groups" tabindex="0">
<optgroup label="Test">
<option value="one">One</option>
<option value="two">Two</option>
</optgroup>
<optgroup label="Empty"></optgroup>
</select>
</div>
<script src="../vendor/qunit-1.14.0.js" type="text/javascript"></script>
<script src="../../vendor/jquery-2.1.0.js" type="text/javascript"></script>
<script src="../../dist/js/select2.full.js" type="text/javascript"></script>
<script src="../helpers.js" type="text/javascript"></script>
<script src="selection-tests.js" type="text/javascript"></script>
</body>
</html>

View File

@ -1,24 +0,0 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="vendor/qunit-1.14.0.js" type="text/javascript"></script>
<script src="../vendor/jquery-2.1.0.js" type="text/javascript"></script>
<script src="../dist/js/select2.full.js" type="text/javascript"></script>
<script src="helpers.js" type="text/javascript"></script>
<script src="data/base-tests.js" type="text/javascript"></script>
<script src="data/inputData-tests.js" type="text/javascript"></script>
<script src="data/maximumInputLength-tests.js" type="text/javascript"></script>
<script src="data/maximumSelectionLength-tests.js" type="text/javascript"></script>
<script src="data/minimumInputLength-tests.js" type="text/javascript"></script>
</body>
</html>

View File

@ -4,7 +4,7 @@ var ArrayData = require('select2/data/array');
var $ = require('jquery');
var Options = require('select2/options');
var options = new Options({
var arrayOptions = new Options({
data: [
{
id: 'default',
@ -41,9 +41,9 @@ var nestedOptions = new Options({
});
test('current gets default for single', function (assert) {
var $select = $('#qunit-fixture .single');
var $select = $('#qunit-fixture .single-empty');
var data = new ArrayData($select, options);
var data = new ArrayData($select, arrayOptions);
data.current(function (val) {
assert.equal(
@ -65,7 +65,7 @@ test('current gets default for single', function (assert) {
test('current gets default for multiple', function (assert) {
var $select = $('#qunit-fixture .multiple');
var data = new ArrayData($select, options);
var data = new ArrayData($select, arrayOptions);
data.current(function (val) {
assert.equal(
@ -79,9 +79,9 @@ test('current gets default for multiple', function (assert) {
test('current works with existing selections', function (assert) {
var $select = $('#qunit-fixture .multiple');
var data = new ArrayData($select, options);
var data = new ArrayData($select, arrayOptions);
$select.val(['3']);
$select.val(['One']);
data.current(function (val) {
assert.equal(
@ -94,22 +94,22 @@ test('current works with existing selections', function (assert) {
assert.equal(
option.id,
'3',
'One',
'The id should be equal to the value of the option tag.'
);
assert.equal(
option.text,
'Three',
'One',
'The text should be equal to the text of the option tag.'
);
});
});
test('current works with selected data', function (assert) {
var $select = $('#qunit-fixture .single');
var $select = $('#qunit-fixture .single-empty');
var data = new ArrayData($select, options);
var data = new ArrayData($select, arrayOptions);
data.select({
id: '2',
@ -140,9 +140,9 @@ test('current works with selected data', function (assert) {
});
test('select works for single', function (assert) {
var $select = $('#qunit-fixture .single');
var $select = $('#qunit-fixture .single-empty');
var data = new ArrayData($select, options);
var data = new ArrayData($select, arrayOptions);
assert.equal(
$select.val(),
@ -165,7 +165,7 @@ test('select works for single', function (assert) {
test('multiple sets the value', function (assert) {
var $select = $('#qunit-fixture .multiple');
var data = new ArrayData($select, options);
var data = new ArrayData($select, arrayOptions);
assert.equal($select.val(), null);
@ -180,24 +180,24 @@ test('multiple sets the value', function (assert) {
test('multiple adds to the old value', function (assert) {
var $select = $('#qunit-fixture .multiple');
var data = new ArrayData($select, options);
var data = new ArrayData($select, arrayOptions);
$select.val(['3']);
$select.val(['One']);
assert.deepEqual($select.val(), ['3']);
assert.deepEqual($select.val(), ['One']);
data.select({
id: 'default',
text: 'Default'
});
assert.deepEqual($select.val(), ['3', 'default']);
assert.deepEqual($select.val(), ['One', 'default']);
});
test('option tags are automatically generated', function (assert) {
var $select = $('#qunit-fixture .single');
var $select = $('#qunit-fixture .single-empty');
var data = new ArrayData($select, options);
var data = new ArrayData($select, arrayOptions);
assert.equal(
$select.find('option').length,
@ -207,7 +207,7 @@ test('option tags are automatically generated', function (assert) {
});
test('optgroup tags can also be generated', function (assert) {
var $select = $('#qunit-fixture .single');
var $select = $('#qunit-fixture .single-empty');
var data = new ArrayData($select, nestedOptions);
@ -225,7 +225,7 @@ test('optgroup tags can also be generated', function (assert) {
});
test('optgroup tags have the right properties', function (assert) {
var $select = $('#qunit-fixture .single');
var $select = $('#qunit-fixture .single-empty');
var data = new ArrayData($select, nestedOptions);

View File

@ -1,25 +0,0 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<select class="single"></select>
<select class="multiple" multiple="multiple">
<option value="3">Three</option>
</select>
</div>
<script src="../vendor/qunit-1.14.0.js" type="text/javascript"></script>
<script src="../../vendor/jquery-2.1.0.js" type="text/javascript"></script>
<script src="../../dist/js/select2.full.js" type="text/javascript"></script>
<script src="../helpers.js" type="text/javascript"></script>
<script src="array-tests.js" type="text/javascript"></script>
</body>
</html>

View File

@ -3,12 +3,12 @@ module('Data adapters - Select - current');
var SelectData = require('select2/data/select');
var $ = require('jquery');
var Options = require('select2/options');
var options = new Options({});
var selectOptions = new Options({});
test('current gets default for single', function (assert) {
var $select = $('#qunit-fixture .single');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
data.current(function (data) {
assert.equal(
@ -21,13 +21,13 @@ test('current gets default for single', function (assert) {
assert.equal(
option.id,
'default',
'One',
'The value of the option tag should be the id'
);
assert.equal(
option.text,
'Default',
'One',
'The text within the option tag should be the text'
);
});
@ -36,7 +36,7 @@ test('current gets default for single', function (assert) {
test('current gets default for multiple', function (assert) {
var $select = $('#qunit-fixture .multiple');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
data.current(function (data) {
assert.equal(
@ -50,7 +50,10 @@ test('current gets default for multiple', function (assert) {
test('current gets options with explicit value', function (assert) {
var $select = $('#qunit-fixture .single');
var data = new SelectData($select, options);
var $option = $('<option value="1">One</option>');
$select.append($option);
var data = new SelectData($select, selectOptions);
$select.val('1');
@ -80,9 +83,9 @@ test('current gets options with explicit value', function (assert) {
test('current gets options with implicit value', function (assert) {
var $select = $('#qunit-fixture .single');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
$select.val('2');
$select.val('One');
data.current(function (val) {
assert.equal(
@ -95,63 +98,63 @@ test('current gets options with implicit value', function (assert) {
assert.equal(
option.id,
'2',
'One',
'The id should be the same as the option text'
);
assert.equal(
option.text,
'2',
'One',
'The text should be the same as the option text'
);
});
});
test('select works for single', function (assert) {
var $select = $('#qunit-fixture .single');
var $select = $('#qunit-fixture .single-with-placeholder');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
assert.equal($select.val(), 'default');
assert.equal($select.val(), 'placeholder');
data.select({
id: '1',
id: 'One',
text: 'One'
});
assert.equal($select.val(), '1');
assert.equal($select.val(), 'One');
});
test('multiple sets the value', function (assert) {
var $select = $('#qunit-fixture .multiple');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
assert.equal($select.val(), null);
data.select({
id: 'default',
text: 'Default'
id: 'Two',
text: 'Two'
});
assert.deepEqual($select.val(), ['default']);
assert.deepEqual($select.val(), ['Two']);
});
test('multiple adds to the old value', function (assert) {
var $select = $('#qunit-fixture .multiple');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
$select.val(['2']);
$select.val(['Two']);
assert.deepEqual($select.val(), ['2']);
assert.deepEqual($select.val(), ['Two']);
data.select({
id: 'default',
text: 'Default'
id: 'One',
text: 'One'
});
assert.deepEqual($select.val(), ['default', '2']);
assert.deepEqual($select.val(), ['One', 'Two']);
});
test('duplicates - single - same id on select triggers change',
@ -311,12 +314,12 @@ module('Data adapter - Select - query');
test('all options are returned with no term', function (assert) {
var $select = $('#qunit-fixture .single');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
data.query({}, function (data) {
assert.equal(
data.results.length,
3,
1,
'The number of items returned should be equal to the number of options'
);
});
@ -325,15 +328,15 @@ test('all options are returned with no term', function (assert) {
test('the matcher checks the text', function (assert) {
var $select = $('#qunit-fixture .single');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
data.query({
term: 'Default'
term: 'One'
}, function (data) {
assert.equal(
data.results.length,
1,
'Only the "Default" option should be found'
'Only the "One" option should be found'
);
});
});
@ -341,7 +344,7 @@ test('the matcher checks the text', function (assert) {
test('the matcher ignores case', function (assert) {
var $select = $('#qunit-fixture .single');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
data.query({
term: 'one'
@ -357,7 +360,7 @@ test('the matcher ignores case', function (assert) {
test('no options may be returned with no matches', function (assert) {
var $select = $('#qunit-fixture .single');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
data.query({
term: 'qwerty'
@ -373,7 +376,7 @@ test('no options may be returned with no matches', function (assert) {
test('optgroup tags are marked with children', function (assert) {
var $select = $('#qunit-fixture .groups');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
data.query({}, function (data) {
assert.ok(
@ -386,7 +389,7 @@ test('optgroup tags are marked with children', function (assert) {
test('empty optgroups are still shown when queried', function (assert) {
var $select = $('#qunit-fixture .groups');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
data.query({}, function (data) {
assert.equal(
@ -414,7 +417,7 @@ test('empty optgroups are still shown when queried', function (assert) {
test('multiple options with the same value are returned', function (assert) {
var $select = $('#qunit-fixture .duplicates');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
data.query({}, function (data) {
assert.equal(
@ -443,7 +446,7 @@ test('multiple options with the same value are returned', function (assert) {
test('data objects use the text of the option', function (assert) {
var $select = $('#qunit-fixture .duplicates');
var data = new SelectData($select, options);
var data = new SelectData($select, selectOptions);
var $option = $('<option>&amp;</option>');

View File

@ -1,51 +0,0 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<select class="single">
<option value="default">Default</option>
<option value="1">One</option>
<option>2</option>
</select>
<select class="multiple" multiple="multiple">
<option value="default">Default</option>
<option value="1">One</option>
<option>2</option>
</select>
<select class="groups">
<optgroup label="Test">
<option value="one">One</option>
<option value="two">Two</option>
</optgroup>
<optgroup label="Empty"></optgroup>
</select>
<select class="duplicates">
<option value="one">One</option>
<option value="two">Two</option>
<option value="one">Uno</option>
</select>
<select class="duplicates-multi" multiple="multiple">
<option value="one">One</option>
<option value="two">Two</option>
<option value="one">Uno</option>
</select>
</div>
<script src="../vendor/qunit-1.14.0.js" type="text/javascript"></script>
<script src="../../vendor/jquery-2.1.0.js" type="text/javascript"></script>
<script src="../../dist/js/select2.full.js" type="text/javascript"></script>
<script src="../helpers.js" type="text/javascript"></script>
<script src="select-tests.js" type="text/javascript"></script>
</body>
</html>

View File

@ -1,23 +0,0 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<select class="single">
<option>One</option>
</select>
</div>
<script src="../vendor/qunit-1.14.0.js" type="text/javascript"></script>
<script src="../../vendor/jquery-2.1.0.js" type="text/javascript"></script>
<script src="../../dist/js/select2.full.js" type="text/javascript"></script>
<script src="../helpers.js" type="text/javascript"></script>
<script src="tags-tests.js" type="text/javascript"></script>
</body>
</html>

View File

@ -1,24 +0,0 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<div class="event-container">
<select></select>
</div>
</div>
<script src="vendor/qunit-1.14.0.js" type="text/javascript"></script>
<script src="../vendor/jquery-2.1.0.js" type="text/javascript"></script>
<script src="../dist/js/select2.full.js" type="text/javascript"></script>
<script src="helpers.js" type="text/javascript"></script>
<script src="dropdown/selectOnClose-tests.js" type="text/javascript"></script>
<script src="dropdown/stopPropagation-tests.js" type="text/javascript"></script>
</body>
</html>

View File

@ -1,27 +0,0 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
</head>
<body>
<style type="text/css">
.css-set-width {
width: 500px;
}
</style>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="vendor/qunit-1.14.0.js" type="text/javascript"></script>
<script src="../vendor/jquery-2.1.0.js" type="text/javascript"></script>
<script src="../dist/js/select2.full.js" type="text/javascript"></script>
<script src="helpers.js" type="text/javascript"></script>
<script src="options/data-tests.js" type="text/javascript"></script>
<script src="options/deprecated-tests.js" type="text/javascript"></script>
<script src="options/width-tests.js" type="text/javascript"></script>
</body>
</html>

View File

@ -29,8 +29,13 @@ test('width from style returns null if nothing is found', function (assert) {
assert.equal(width, null);
});
test('width from computer element width', function (assert) {
test('width from computed element width', function (assert) {
var $style = $(
'<style type="text/css">.css-set-width { width: 500px; }</style>'
);
var $test = $('<select class="css-set-width"></select>');
$('#qunit-fixture').append($style);
$('#qunit-fixture').append($test);
var width = select._resolveWidth($test, 'element');
@ -47,7 +52,12 @@ test('resolve gets the style if it is there', function (assert) {
});
test('resolve falls back to element if there is no style', function (assert) {
var $style = $(
'<style type="text/css">.css-set-width { width: 500px; }</style>'
);
var $test = $('<select class="css-set-width"></select>');
$('#qunit-fixture').append($style);
$('#qunit-fixture').append($test);
var width = select._resolveWidth($test, 'resolve');

85
tests/runner.html Normal file
View File

@ -0,0 +1,85 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<div class="event-container">
<select></select>
</div>
<select class="single">
<option>One</option>
</select>
<select class="single-empty"></select>
<select class="single-with-placeholder">
<option>placeholder</option>
<option>One</option>
</select>
<select class="multiple" multiple="multiple">
<option>One</option>
<option>Two</option>
</select>
<select class="groups">
<optgroup label="Test">
<option value="one">One</option>
<option value="two">Two</option>
</optgroup>
<optgroup label="Empty"></optgroup>
</select>
<select class="duplicates">
<option value="one">One</option>
<option value="two">Two</option>
<option value="one">Uno</option>
</select>
<select class="duplicates-multi" multiple="multiple">
<option value="one">One</option>
<option value="two">Two</option>
<option value="one">Uno</option>
</select>
</div>
<script src="vendor/qunit-1.14.0.js" type="text/javascript"></script>
<script src="../vendor/jquery-2.1.0.js" type="text/javascript"></script>
<script src="../dist/js/select2.full.js" type="text/javascript"></script>
<script src="helpers.js" type="text/javascript"></script>
<script src="a11y/selection-tests.js" type="text/javascript"></script>
<script src="data/array-tests.js" type="text/javascript"></script>
<script src="data/base-tests.js" type="text/javascript"></script>
<script src="data/inputData-tests.js" type="text/javascript"></script>
<script src="data/select-tests.js" type="text/javascript"></script>
<script src="tags-tests.js" type="text/javascript"></script>
<script src="data/maximumInputLength-tests.js" type="text/javascript"></script>
<script src="data/maximumSelectionLength-tests.js" type="text/javascript"></script>
<script src="data/minimumInputLength-tests.js" type="text/javascript"></script>
<script src="dropdown/selectOnClose-tests.js" type="text/javascript"></script>
<script src="dropdown/stopPropagation-tests.js" type="text/javascript"></script>
<script src="options/data-tests.js" type="text/javascript"></script>
<script src="options/deprecated-tests.js" type="text/javascript"></script>
<script src="options/width-tests.js" type="text/javascript"></script>
<script src="selection/allowClear-tests.js" type="text/javascript"></script>
<script src="selection/multiple-tests.js" type="text/javascript"></script>
<script src="selection/placeholder-tests.js" type="text/javascript"></script>
<script src="selection/single-tests.js" type="text/javascript"></script>
<script src="selection/stopPropagation-tests.js" type="text/javascript"></script>
<script src="utils/decorator-tests.js" type="text/javascript"></script>
<script src="utils/escapeMarkup-tests.js" type="text/javascript"></script>
</body>
</html>

View File

@ -1,37 +0,0 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<select class="single">
<option>One</option>
</select>
<select class="single-with-placeholder">
<option>placeholder</option>
<option>One</option>
</select>
<select class="multiple" multiple="multiple">
<option>One</option>
<option>Two</option>
</select>
</div>
<script src="vendor/qunit-1.14.0.js" type="text/javascript"></script>
<script src="../vendor/jquery-2.1.0.js" type="text/javascript"></script>
<script src="../dist/js/select2.full.js" type="text/javascript"></script>
<script src="helpers.js" type="text/javascript"></script>
<script src="selection/allowClear-tests.js" type="text/javascript"></script>
<script src="selection/multiple-tests.js" type="text/javascript"></script>
<script src="selection/placeholder-tests.js" type="text/javascript"></script>
<script src="selection/single-tests.js" type="text/javascript"></script>
<script src="selection/stopPropagation-tests.js" type="text/javascript"></script>
</body>
</html>

View File

@ -1,20 +0,0 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" />
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="vendor/qunit-1.14.0.js" type="text/javascript"></script>
<script src="../vendor/jquery-2.1.0.js" type="text/javascript"></script>
<script src="../dist/js/select2.full.js" type="text/javascript"></script>
<script src="helpers.js" type="text/javascript"></script>
<script src="utils/decorator-tests.js" type="text/javascript"></script>
<script src="utils/escapeMarkup-tests.js" type="text/javascript"></script>
</body>
</html>