mirror of
https://github.com/pebble-dev/clay.git
synced 2026-08-28 04:46:57 -04:00
only dispatch manipulator events if the state is actually changed.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
var assert = require('chai').assert;
|
||||
var fixture = require('../../fixture');
|
||||
|
||||
describe('component - color', function() {
|
||||
describe('component - select', function() {
|
||||
it('sets the value display to the correct value on change', function() {
|
||||
var clayConfig = fixture.clayConfig([
|
||||
{
|
||||
|
||||
@@ -19,9 +19,10 @@ describe('manipulators', function() {
|
||||
it('sets: "' + value + '" and gets: "' + expected + '" then triggers "change"',
|
||||
function() {
|
||||
var handlerSpy = sinon.spy();
|
||||
var clayItem = fixture.clayItem(itemType);
|
||||
var clayItem = fixture.clayConfig([itemType]).getAllItems()[0];
|
||||
clayItem.on('change', handlerSpy);
|
||||
|
||||
clayItem.set(value);
|
||||
clayItem.set(value);
|
||||
assert.deepEqual(clayItem.get(), expected);
|
||||
assert.strictEqual(handlerSpy.callCount, 1, 'handler not called once');
|
||||
@@ -45,6 +46,7 @@ describe('manipulators', function() {
|
||||
false
|
||||
);
|
||||
clayItem.disable();
|
||||
clayItem.disable();
|
||||
assert.strictEqual(
|
||||
clayItem.$element[0].classList.contains('disabled'),
|
||||
true
|
||||
@@ -73,6 +75,7 @@ describe('manipulators', function() {
|
||||
true
|
||||
);
|
||||
clayItem.enable();
|
||||
clayItem.enable();
|
||||
assert.strictEqual(
|
||||
clayItem.$element[0].classList.contains('disabled'),
|
||||
false
|
||||
@@ -100,6 +103,7 @@ describe('manipulators', function() {
|
||||
false
|
||||
);
|
||||
clayItem.hide();
|
||||
clayItem.hide();
|
||||
assert.strictEqual(
|
||||
clayItem.$element[0].classList.contains('hide'),
|
||||
true
|
||||
@@ -127,6 +131,7 @@ describe('manipulators', function() {
|
||||
true
|
||||
);
|
||||
clayItem.show();
|
||||
clayItem.show();
|
||||
assert.strictEqual(
|
||||
clayItem.$element[0].classList.contains('hide'),
|
||||
false
|
||||
@@ -145,6 +150,7 @@ describe('manipulators', function() {
|
||||
|
||||
describe('val', function() {
|
||||
testSetGet('input', 'test321');
|
||||
testSetGet('input', 1234, '1234');
|
||||
testDisable('input');
|
||||
testEnable('input');
|
||||
testShow('text');
|
||||
@@ -152,10 +158,10 @@ describe('manipulators', function() {
|
||||
});
|
||||
|
||||
describe('checked', function() {
|
||||
testSetGet('toggle', true, 1);
|
||||
testSetGet('toggle', 1);
|
||||
testSetGet('toggle', false, 0);
|
||||
testSetGet('toggle', 0);
|
||||
testSetGet({type: 'toggle', defaultValue: 0}, true, 1);
|
||||
testSetGet({type: 'toggle', defaultValue: 0}, 1);
|
||||
testSetGet({type: 'toggle', defaultValue: 1}, false, 0);
|
||||
testSetGet({type: 'toggle', defaultValue: 1}, 0);
|
||||
testDisable('toggle');
|
||||
testEnable('toggle');
|
||||
testShow('toggle');
|
||||
@@ -185,6 +191,7 @@ describe('manipulators', function() {
|
||||
var item = {
|
||||
type: 'checkboxgroup',
|
||||
clayId: 1,
|
||||
defaultValue: ['two'],
|
||||
options: [
|
||||
{ label: '1', value: 'one' },
|
||||
{ label: '2', value: 'two' },
|
||||
@@ -207,9 +214,9 @@ describe('manipulators', function() {
|
||||
testSetGet('color', '0xFF0000', 0xff0000);
|
||||
testSetGet('color', '#ff0000', 0xff0000);
|
||||
testSetGet('color', 0xff0000, 0xff0000);
|
||||
testSetGet('color', '', 0x000000);
|
||||
testSetGet('color', false, 0x000000);
|
||||
testSetGet('color', undefined, 0x000000);
|
||||
testSetGet({type: 'color', defaultValue: 0x00ff00}, '', 0x000000);
|
||||
testSetGet({type: 'color', defaultValue: 0x00ff00}, false, 0x000000);
|
||||
testSetGet({type: 'color', defaultValue: 0x00ff00}, undefined, 0x000000);
|
||||
testDisable('color');
|
||||
testEnable('color');
|
||||
testShow('color');
|
||||
|
||||
Reference in New Issue
Block a user