Clean up manipulators tests

This commit is contained in:
Keegan
2016-03-10 00:03:50 +11:00
parent 3b7c4cda7c
commit 0faa585d5f
+58 -53
View File
@@ -143,43 +143,47 @@ describe('manipulators', function() {
} }
describe('html', function() { describe('html', function() {
testSetGet('text', 'test123'); var type = 'text';
testSetGet('button', '<span>some HTML</span>'); testSetGet(type, 'test123');
testShow('text'); testSetGet(type, '<span>some HTML</span>');
testHide('text'); testShow(type);
testHide(type);
}); });
describe('button', function() { describe('button', function() {
testSetGet('button', 'test123'); var type = 'button';
testSetGet('button', '<span>some HTML</span>'); testSetGet(type, 'test123');
testDisable('button'); testSetGet(type, '<span>some HTML</span>');
testEnable('button'); testDisable(type);
testShow('button'); testEnable(type);
testHide('button'); testShow(type);
testHide(type);
}); });
describe('val', function() { describe('val', function() {
testSetGet('input', 'test321'); var type = 'input';
testSetGet('input', 1234, '1234'); testSetGet(type, 'test321');
testDisable('input'); testSetGet(type, 1234, '1234');
testEnable('input'); testDisable(type);
testShow('text'); testEnable(type);
testHide('text'); testShow(type);
testHide(type);
}); });
describe('checked', function() { describe('checked', function() {
testSetGet({type: 'toggle', defaultValue: false}, 1, true); var type = 'toggle';
testSetGet({type: 'toggle', defaultValue: false}, true); testSetGet({type: type, defaultValue: false}, 1, true);
testSetGet({type: 'toggle', defaultValue: true}, 0, false); testSetGet({type: type, defaultValue: false}, true);
testSetGet({type: 'toggle', defaultValue: true}, false); testSetGet({type: type, defaultValue: true}, 0, false);
testDisable('toggle'); testSetGet({type: type, defaultValue: true}, false);
testEnable('toggle'); testDisable(type);
testShow('toggle'); testEnable(type);
testHide('toggle'); testShow(type);
testHide(type);
}); });
describe('radiogroup', function() { describe('radiogroup', function() {
var item = { var type = {
type: 'radiogroup', type: 'radiogroup',
clayId: 1, clayId: 1,
options: [ options: [
@@ -188,17 +192,17 @@ describe('manipulators', function() {
{ label: '3', value: 'three "quote' } { label: '3', value: 'three "quote' }
] ]
}; };
testSetGet(item, 'one'); testSetGet(type, 'one');
testSetGet(item, 'two'); testSetGet(type, 'two');
testSetGet(item, 'three "quote'); testSetGet(type, 'three "quote');
testDisable(item); testDisable(type);
testEnable(item); testEnable(type);
testShow(item); testShow(type);
testHide(item); testHide(type);
}); });
describe('checkboxgroup', function() { describe('checkboxgroup', function() {
var item = { var type = {
type: 'checkboxgroup', type: 'checkboxgroup',
clayId: 1, clayId: 1,
defaultValue: ['two'], defaultValue: ['two'],
@@ -208,28 +212,29 @@ describe('manipulators', function() {
{ label: '3', value: 'three "quote' } { label: '3', value: 'three "quote' }
] ]
}; };
testSetGet(item, ['one', 'two']); testSetGet(type, ['one', 'two']);
testSetGet(item, ['three "quote']); testSetGet(type, ['three "quote']);
testSetGet(item, []); testSetGet(type, []);
testSetGet(item, false, []); testSetGet(type, false, []);
testDisable(item); testDisable(type);
testEnable(item); testEnable(type);
testShow(item); testShow(type);
testHide(item); testHide(type);
}); });
describe('color', function() { describe('color', function() {
testSetGet('color', 'FF0000', 0xff0000); var type = 'color';
testSetGet('color', '#FF0000', 0xff0000); testSetGet(type, 'FF0000', 0xff0000);
testSetGet('color', '0xFF0000', 0xff0000); testSetGet(type, '#FF0000', 0xff0000);
testSetGet('color', '#ff0000', 0xff0000); testSetGet(type, '0xFF0000', 0xff0000);
testSetGet('color', 0xff0000, 0xff0000); testSetGet(type, '#ff0000', 0xff0000);
testSetGet({type: 'color', defaultValue: 0x00ff00}, '', 0x000000); testSetGet(type, 0xff0000, 0xff0000);
testSetGet({type: 'color', defaultValue: 0x00ff00}, false, 0x000000); testSetGet({type: type, defaultValue: 0x00ff00}, '', 0x000000);
testSetGet({type: 'color', defaultValue: 0x00ff00}, undefined, 0x000000); testSetGet({type: type, defaultValue: 0x00ff00}, false, 0x000000);
testDisable('color'); testSetGet({type: type, defaultValue: 0x00ff00}, undefined, 0x000000);
testEnable('color'); testDisable(type);
testShow('color'); testEnable(type);
testHide('color'); testShow(type);
testHide(type);
}); });
}); });