mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-31 15:12:07 +03:00
Add tests for addClass/removeClass
This commit is contained in:
parent
f235d7a642
commit
31d4cc13b7
@ -17,6 +17,7 @@
|
||||
<script src="/test/test.js"></script>
|
||||
<script src="/test/basic.js"></script>
|
||||
<script src="/test/strings.js"></script>
|
||||
<script src="/test/utils.js"></script>
|
||||
<script src="/test/dzi-jsonp.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
52
test/utils.js
Normal file
52
test/utils.js
Normal file
@ -0,0 +1,52 @@
|
||||
(function() {
|
||||
module("utils");
|
||||
|
||||
test("addRemoveClass", function() {
|
||||
var div = OpenSeadragon.makeNeutralElement('div');
|
||||
strictEqual(div.className, '',
|
||||
"makeNeutralElement set no classes");
|
||||
|
||||
OpenSeadragon.addClass(div, 'foo');
|
||||
strictEqual(div.className, 'foo',
|
||||
"Added first class");
|
||||
OpenSeadragon.addClass(div, 'bar');
|
||||
strictEqual(div.className, 'foo bar',
|
||||
"Added second class");
|
||||
OpenSeadragon.addClass(div, 'baz');
|
||||
strictEqual(div.className, 'foo bar baz',
|
||||
"Added third class");
|
||||
OpenSeadragon.addClass(div, 'plugh');
|
||||
strictEqual(div.className, 'foo bar baz plugh',
|
||||
"Added fourth class");
|
||||
|
||||
OpenSeadragon.addClass(div, 'foo');
|
||||
strictEqual(div.className, 'foo bar baz plugh',
|
||||
"Re-added first class");
|
||||
OpenSeadragon.addClass(div, 'bar');
|
||||
strictEqual(div.className, 'foo bar baz plugh',
|
||||
"Re-added middle class");
|
||||
OpenSeadragon.addClass(div, 'plugh');
|
||||
strictEqual(div.className, 'foo bar baz plugh',
|
||||
"Re-added last class");
|
||||
|
||||
OpenSeadragon.removeClass(div, 'xyzzy');
|
||||
strictEqual(div.className, 'foo bar baz plugh',
|
||||
"Removed nonexistent class");
|
||||
OpenSeadragon.removeClass(div, 'ba');
|
||||
strictEqual(div.className, 'foo bar baz plugh',
|
||||
"Removed nonexistent class with existent substring");
|
||||
|
||||
OpenSeadragon.removeClass(div, 'bar');
|
||||
strictEqual(div.className, 'foo baz plugh',
|
||||
"Removed middle class");
|
||||
OpenSeadragon.removeClass(div, 'plugh');
|
||||
strictEqual(div.className, 'foo baz',
|
||||
"Removed last class");
|
||||
OpenSeadragon.removeClass(div, 'foo');
|
||||
strictEqual(div.className, 'baz',
|
||||
"Removed first class");
|
||||
OpenSeadragon.removeClass(div, 'baz');
|
||||
strictEqual(div.className, '',
|
||||
"Removed only class");
|
||||
});
|
||||
})();
|
Loading…
x
Reference in New Issue
Block a user