Debian Codegraph @

closure-library/closure/goog/ui/customcolorpalette_test.js

raw
1 // Copyright 2008 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 goog.provide('goog.ui.CustomColorPaletteTest');
16 goog.setTestOnly('goog.ui.CustomColorPaletteTest');
17
18 goog.require('goog.dom.TagName');
19 goog.require('goog.dom.classlist');
20 goog.require('goog.testing.jsunit');
21 goog.require('goog.ui.CustomColorPalette');
22
23 var samplePalette;
24
25 function setUp() {
26 samplePalette = new goog.ui.CustomColorPalette();
27 }
28
29 function tearDown() {
30 samplePalette.dispose();
31 document.getElementById('sandbox').innerHTML = '';
32 }
33
34 function testRender() {
35 samplePalette.render(document.getElementById('sandbox'));
36
37 assertTrue('Palette must have been rendered', samplePalette.isInDocument());
38
39 var elem = samplePalette.getElement();
40 assertNotNull('The palette element should not be null', elem);
41 assertEquals(
42 'The palette element should have the right tag name',
43 String(goog.dom.TagName.DIV), elem.tagName);
44
45 assertTrue(
46 'The custom color palette should have the right class name',
47 goog.dom.classlist.contains(elem, 'goog-palette'));
48 }
49
50 function testSetColors() {
51 var colorSet = [
52 '#e06666', '#f6b26b', '#ffd966', '#93c47d', '#76a5af', '#6fa8dc', '#8e7cc3'
53 ];
54 samplePalette.setColors(colorSet);
55 assertSameElements(
56 'The palette should have the correct set of colors', colorSet,
57 samplePalette.getColors());
58 }