| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 (function() { | |
| 27 | |
| 28 module('Utilities'); | |
| 29 | |
| 30 test('hasStyleClass', 11, function() { | |
| 31 var element = document.createElement('div'); | |
| 32 | |
| 33 ok(!element.hasStyleClass('foo')); | |
| 34 ok(!element.hasStyleClass('bar')); | |
| 35 | |
| 36 element.className = 'foo'; | |
| 37 ok(element.hasStyleClass('foo')) | |
| 38 ok(!element.hasStyleClass('bar')); | |
| 39 | |
| 40 element.className = 'foo foo'; | |
| 41 ok(element.hasStyleClass('foo')) | |
| 42 ok(!element.hasStyleClass('bar')); | |
| 43 | |
| 44 element.className = 'foo bar'; | |
| 45 ok(element.hasStyleClass('foo')) | |
| 46 ok(element.hasStyleClass('bar')); | |
| 47 ok(!element.hasStyleClass('baz')); | |
| 48 | |
| 49 element.className = 'food'; | |
| 50 ok(!element.hasStyleClass('foo')); | |
| 51 ok(element.hasStyleClass('food')); | |
| 52 }); | |
| 53 | |
| 54 test('addStyleClass', 4, function() { | |
| 55 var element = document.createElement('div'); | |
| 56 | |
| 57 element.addStyleClass('foo'); | |
| 58 equal(element.className, ' foo'); | |
| 59 | |
| 60 element.addStyleClass('foo'); | |
| 61 equal(element.className, ' foo'); | |
| 62 | |
| 63 element.addStyleClass('bar'); | |
| 64 equal(element.className, ' foo bar'); | |
| 65 | |
| 66 element.addStyleClass('foo'); | |
| 67 equal(element.className, ' foo bar'); | |
| 68 }); | |
| 69 | |
| 70 test('removeStyleClass', 8, function() { | |
| 71 var element = document.createElement('div'); | |
| 72 | |
| 73 element.removeStyleClass('foo'); | |
| 74 equal(element.className, ''); | |
| 75 | |
| 76 element.className = 'foo'; | |
| 77 element.removeStyleClass('foo'); | |
| 78 equal(element.className, ''); | |
| 79 | |
| 80 element.className = ' foo'; | |
| 81 element.removeStyleClass('foo'); | |
| 82 equal(element.className, ' '); | |
| 83 | |
| 84 element.className = 'foo foo'; | |
| 85 element.removeStyleClass('foo'); | |
| 86 equal(element.className, ' '); | |
| 87 | |
| 88 element.className = 'foo bar'; | |
| 89 element.removeStyleClass('foo'); | |
| 90 equal(element.className, ' bar'); | |
| 91 | |
| 92 element.className = 'foo bar foo bar'; | |
| 93 element.removeStyleClass('bar'); | |
| 94 equal(element.className, 'foo foo '); | |
| 95 | |
| 96 element.className = 'food'; | |
| 97 element.removeStyleClass('foo'); | |
| 98 equal(element.className, 'food'); | |
| 99 | |
| 100 element.className = 'foo'; | |
| 101 element.removeStyleClass('food'); | |
| 102 equal(element.className, 'foo'); | |
| 103 }); | |
| 104 | |
| 105 test('toggleStyleClass', 5, function() { | |
| 106 var element = document.createElement('div'); | |
| 107 | |
| 108 element.toggleStyleClass('foo'); | |
| 109 equal(element.className, ' foo'); | |
| 110 | |
| 111 element.toggleStyleClass('foo'); | |
| 112 equal(element.className, ' '); | |
| 113 | |
| 114 element.className = 'bar'; | |
| 115 element.toggleStyleClass('foo'); | |
| 116 equal(element.className, 'bar foo'); | |
| 117 | |
| 118 element.className = 'food'; | |
| 119 element.toggleStyleClass('foo'); | |
| 120 equal(element.className, 'food foo'); | |
| 121 | |
| 122 element.className = 'foo'; | |
| 123 element.toggleStyleClass('food'); | |
| 124 equal(element.className, 'foo food'); | |
| 125 }); | |
| 126 | |
| 127 })(); | |
| OLD | NEW |