1
0
mirror of synced 2024-11-22 21:16:10 +03:00
Commit Graph

5 Commits

Author SHA1 Message Date
Kevin Brown
9491e1aae2
Test against jQuery 3.4.1 (#5531)
* Update tests to be compatible with jQuery 3.0.0

There was a change in jQuery 3 that ensures that the return value of `.val()` on a multiple select is always an array. This is a breaking change from previous versions, where `null` or `undefined` were returned in these scenarios. Because we cannot `assert.equal` on a list of possible values, these assertions were switched to `assert.ok` which should be good enough.

* Properly strip out units in positioning tests

Before we were assuming that there were no units, and only were we stripping them out if we were expecting 3 digits. Now we just strip out all non-digit characters, so that should do the job and get us what we want.

There was a change in jQuery 3.2.0 that caused the units to be returned in these specific calls. They were not previously being returned, so this was not actually an issue.

* Add automated testing against jQuery 3.4.1

No tests appear to be currently failing.
2019-06-25 22:05:15 -04:00
Kevin Brown
650035cf38
Restore compatibility with data-* attributes in jQuery 2.x (#5486)
* Start running tests against jQuery 2.x

We were only running tests against jQuery 1.x before and they were
all passing. This was a problem because apparently all of the data-*
attribute tests fail in jQuery 2.x.  We are now running both the
integration and unit tests against both jQuery 1.x and jQuery 2.x.

Right now this resulted in a complete duplication of the test files
because there wasn't an obvious way to run the tests against both
versions. We're going to look into removing this duplication in the
future once the current issues are fixed.

We are also going to look into testing against jQuery 3.x in the
future, since that is also a supported line of jQuery.

* Force the data-* attributes to be parsed

There was a change made that switched us from using `$.data` and
`$.fn.data` internally to using an internal data store (managed
through internal utilities). This had the unfortunate side effect
of breaking the automatic loading of data-* options in versions of
jQuery other than 1.x, which included anything that would be
considered modern jQuery. While the change was made and approved
in good faith, all of the tests passed and the docs pages appeared
to be working, the tests really failed when running on newer versions
of jQuery. This was confirmed when we started running automated tests
against both versions, which confirmed the bug that others have been
seeing for a while.

The change was made becuase calling `$.fn.data` on an element which
contains a reference to itself in the internal jQuery data cache
would cause a stack overflow. This bug was well documented at the
following GitHub ticket and was resolved by no longer using
`$.fn.data`: https://github.com/select2/select2/issues/4014

Unfortunately because `$.fn.data` was no longer being called in a
way such that all of the data attributes would be dumped out, we
needed to find a replacement. The substitute that was given in the
original bug fix worked when the data cache was fully primed, but
we never primed it anywhere so it actually failed in the general
case. That meant we needed to find a way to manually prime it,
which is exactly what this change does.

* Clean up select2/utils
2019-04-27 22:20:56 -04:00
Kevin Brown
a75482fd30 Upgrades QUnit to 1.23.1
This was required for us to get assert.async() support within tests, as
well as assert.expect() support. This was required because we need them
for multiple async tests that are coming.
2016-05-23 23:25:13 -04:00
Kevin Brown
b9b55cec44 Tests use jQuery 1.7.2
As jQuery 1.7.2 is the lowest version of jQuery supported by Select2,
it makes sense to run the tests on it. For the most part, we can
assume that the newer versions of Select2 are backwards compatible
enough such that this isn't an issue.

The recommended version of jQuery to use is the latest though, which
is why the jQuery file is only included in the tests.

This revealed a few issues with our data fallbacks and `.append`
functionality that was introduced in jQuery 1.8.
2015-03-11 19:20:41 -04:00
Kevin Brown
792133ce5c Added Utils.Decorate and tests
This adds decorator support in a very basic way, but enough that
it doesn't take a lot of effort to get it implemented.

This also starts work on splitting things out for theming.
2014-10-21 21:43:56 -04:00