1
0
mirror of synced 2024-11-23 05:26:10 +03:00
Commit Graph

41 Commits

Author SHA1 Message Date
alexweissman
62c4f6332b Merge branch 'master' of https://github.com/NadeemAfana/select2 into develop 2017-10-26 14:03:02 -04:00
alexweissman
58d9836b7d minor formatting fixes for #5093 2017-10-25 16:55:40 -04:00
Julian Yuste
b11d6e20b0 Fix for issue #4632 2017-10-25 18:25:50 +02:00
Kevin Brown
0358ee5287 Added two test cases (zero and empty string check)
This adds two test cases for 16b4840c0e.
2016-12-29 19:25:37 -05:00
Kevin Brown
1167bace78 Added tests for case insensitive tag matching
This adds a single test for cb9a904578.
2016-12-29 18:29:04 -05:00
Kevin Brown
a74547aaa7 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.
2016-05-23 23:38:45 -04:00
Nadim Afana
6e9657105b Fixed indentation. 2016-05-06 12:23:58 -07:00
Nadim Afana
a1dc7f23d1 Fixed unit tests and updated source code to handle HTML5 attribs. 2016-05-05 21:41:20 -07:00
Kevin Brown
120672dce7 Added tests for multiple tags and tokenizing
This adds tests to ensure that 3b8cd2e369
will continue to work in the future.
2016-03-27 18:37:27 -04:00
Kevin Brown
db5e947664 Added test for new insertTag option
This adds a basic test that ensures that the `insertTag` option works as
expected.
2016-01-03 19:09:45 -05:00
Kevin Brown
d1ed0a513a Add failing test for existing array selections
This adds a broken test that demonstrates the issue seen in
https://github.com/select2/select2/issues/3990 where existing selected
options are being reset once Select2 is initialized. This issue cannot
be reproduced on the options page [1] because the issue only appear to
happen if the selected option is not the first one in the list of
possible options.

[1]: https://select2.github.io/examples.html#data-array
2016-01-03 18:21:09 -05:00
Kevin Brown
a86c2e709f Add tests for 4958961 2015-08-21 19:17:00 -04:00
Kevin Brown
d9c1cbc976 Add tests for d08cb87 2015-08-21 18:32:10 -04:00
Phil Eberhardt
af212fa530 added test for #3564 fix 2015-07-11 22:11:55 -04:00
Kevin Brown
4fb079b34f 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.
2015-03-11 18:51:55 -04:00
Kevin Brown
610381be4a Strip whitespace by default for tags
This strips whitespace in tags by default, so multiple tags cannot
be created with only whitespace as the difference in the id.

A test has been added to ensure that this remains fixed in the future.

This closes https://github.com/select2/select2/issues/3076.
2015-03-11 18:23:10 -04:00
Kevin Brown
0da15aa586 Fixed option text encoding
This fixes an issue when using a `<select>` where the elements were
created with XHTML-encoded characters to prevent any injection, as
they would be double-encoded and display incorrectly.

When using a `<select>`, we can assume that the data has already
been encoded because any XSS will have already run before we get to
it.  Because of this, we can just use `.text()` instead of `.html()`
to avoid any issues.

This also includes a test to ensure that this does not become an
issue in the future.

This closes https://github.com/select2/select2/issues/3115.
2015-03-11 18:12:14 -04:00
Cristi Badila
24f3c4777d Fixes issues with inputData module. When unselecting an item it would previously unselect all items 2015-03-10 19:16:17 +02:00
Kevin Brown
e9bfa72966 Added tests for the <input /> element 2015-02-27 18:37:06 -05:00
Kevin Brown
72e5c2a50d Combine tests into common files
This groups tests into common HTML files so they can be run more
quickly. This also reduces the number of Sauce Labs instances that
have to be run, as one instance was previously spun up for each
file.
2015-02-13 23:29:56 -05:00
Kevin Brown
686f846fa5 Changed how the builds are done
This adds a check that triggers an error if Select2 was not able
to detect a copy of jQuery on the page. This should help users when
they are setting up Select2.

**Breaking change:** The full build no longer includes jQuery.
Previously, the full build included all requirements for Select2,
including jQuery, which meant that anyone looking for the optional
requirements had to possibly include multiple versions of jQuery
on their page. This means that anyone requiring Select2 to also
bundle jQuery will now need to include jQuery on their pages
alongside Select2. A copy of jQuery is included in the repository.

**Breaking change:** The AMD build of Select2 will now correctly
wrap the code in a `define` block. It will still create the named
blocks inside of the code, which should be valid in most AMD build
systems, so now Select2 is compatible with cases where the file
does not have the same name as the Select2 module name.

**Breaking change:** Select2 will re-use the AMD methods if they
are available on the page, but it will not longer leak the included
AMD loader to the global scope. The AMD methods will still be
available on the `jQuery.fn.select2.amd` namespace.

The `mock.js` test file has been renamed to `helpers.js` and will
handle the escalation of the `require` and `define` variables to
the global scope. It should be included in all test files, or the
tests will fail.

This closes https://github.com/select2/select2/issues/2946.
2015-01-22 14:49:39 -05:00
Zubair
7515fa7f46 only verify when maximumSelectionCount is greater than 0 and add tests 2015-01-13 13:00:16 -05:00
Kevin Brown
ff596e692e Added a few more tests
This adds a test that makes sure that the inline data attribute
overrides the options that are passed in during initialization.

This also adds a test for the `createTag` option, which is used
when tagging.
2015-01-11 16:30:16 -05:00
Kevin Brown
7f17291932 Fix support for deep nesting
While deep nesting will not work on a standard `<select>`, we can
emulate it through data objects still, and just handle the display
of the data in the results.

This also means that the horrific deep-nested CSS is back to handle
the padding. I hope that will get fixed over time.

This also fixes one of the performance issues with adding array
data, as options are added at the very end instead of one by one.
2015-01-09 20:50:06 -05:00
Kevin Brown
05cbaf7bf7 Universally use the object query return
There was a plan to universally use an array as the return from
query methods, but now that we've realized pagination and extra
things are impossible without it, we're going back to the return
object. Anyone looking to migrate their data should be returning
an object with the key `results` containing what they previously
returned.

This should fix https://github.com/select2/select2/issues/2898
2015-01-07 21:11:32 -05:00
Kevin Brown
0bc73941fe Support duplicate options
Now that the data objects have the `element` property, we can test
to make sure it's a DOM element and then use it for selecting the
option. This allows us to select multiple options with the same id,
as well as handle cases where that is already happening.

You cannot use `$e.val()` to select two options with the same id,
as jQuery will reject it, but you can set the second option to
`.selected = true`, which is supported.
2014-12-17 20:36:06 -05:00
Kevin Brown
e3647051de Added maximumInputLength support 2014-11-26 21:52:49 -05:00
Kevin Brown
56d5778590 Finished off tests for tags
This also adds back the ability for tags to return `null` in order
for no tag to be added to the results.
2014-11-26 19:53:15 -05:00
Kevin Brown
76e4ea8340 Added tests for tags 2014-11-25 21:28:16 -05:00
Kevin Brown
16e565e28e Added tests for minimumInputLength 2014-11-25 20:12:17 -05:00
Kevin Brown
05ddbec1a7 Improve data array speeds
This improves the speeds of creating the `<option>` tags for array
data. By creating the HTML ahead of time and putting it into an
`<option>` element before passing it to jQuery, it cuts down on the
time it takes for jQuery to process the HTML string and convert it
into DOM elements. This proved to be incredibly slow.

This also changes the `item` function to return early when the
data exists. The `$e.data` call has also been switched to a
`$.data` call, which doesn't need to check the DOM to see if the
data attributes already exist. This cuts down on a bit of wasted
time, as the `data` key should never be present in the DOM, and it
should be ignored if it is.
2014-11-07 11:17:37 -05:00
Kevin Brown
8158e151ff Added test to make sure the options are generated 2014-11-06 12:12:43 -05:00
Kevin Brown
8ea23610f1 Convert array data to options immediately
This converts individual objects passed in through the `array`
parameter to `<option>` tags when Select2 is initialized. This
removes a lot of duplicate code from the `ArrayAdapter`, and keeps
everything closer to the native `<select>` element.

This introduces a breaking change from previous versions of Select2,
where the initial value for array data was blank, even if a blank
option was not present in the original array of objects. Now the
first object passed in will be selected by default, following the
behavior of a standard `<select>` element.

This breaking change does not affect `<select multiple="multiple">`
elements, which by default have no selection.
2014-11-06 12:05:12 -05:00
Kevin Brown
9e130956fc Better compatibility with array data
When using array data, and an option is selected, the data that is
attached to the DOM element will be run through `item` and should
have any private, automatically generated attributes added and
merged with it.
2014-10-21 21:44:00 -04:00
Kevin Brown
e018a6f69e Changed tests to not use deepEqual
We should only be checking the option values that matter, such as
`id` and `text`, instead of checking all of the option values. This
will prevent unexpected breaking when new properties are added to
the options.

Existing properties should be covered by tests to avoid regressions.
2014-10-21 21:44:00 -04:00
Kevin Brown
d0fe07f954 Added tests for the query function 2014-10-21 21:43:59 -04:00
Kevin Brown
27ac50a854 Fixed problems with non-string ids
We have to enforce ids being strings as the values of options within
a select will always be an id.  This fixes an issue that we had with
array selections not being highlighted in the results.
2014-10-21 21:43:59 -04:00
Kevin Brown
cbfe23eb52 Added basic tests for select2/data/array 2014-10-21 21:43:58 -04:00
Kevin Brown
5f176b66f2 Add tests for select data adapter 2014-10-21 21:43:58 -04:00
Kevin Brown
0bc56a922b Linted tests 2014-10-21 21:43:57 -04:00
Kevin Brown
114732ec25 Broke out a base data adapter
This should allow us to create a basic interface that all adapters
must follow.
2014-10-21 21:43:57 -04:00