diff --git a/packages/switch/index.tsx b/packages/switch/index.tsx index e8e5dcef2..900b9ecc1 100644 --- a/packages/switch/index.tsx +++ b/packages/switch/index.tsx @@ -35,10 +35,10 @@ function Switch( const switchStyle = { fontSize: size, - backgroundColor: value ? activeColor : inactiveColor + backgroundColor: checked ? activeColor : inactiveColor }; - const loadingColor = value ? activeColor || BLUE : inactiveColor || GRAY_DARK; + const loadingColor = checked ? activeColor || BLUE : inactiveColor || GRAY_DARK; function onClick() { if (!disabled && !loading) { diff --git a/packages/switch/test/__snapshots__/index.spec.js.snap b/packages/switch/test/__snapshots__/index.spec.js.snap new file mode 100644 index 000000000..d2a276311 --- /dev/null +++ b/packages/switch/test/__snapshots__/index.spec.js.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`inactive-color prop 1`] = ` +
+
+
+`; diff --git a/packages/switch/test/index.spec.js b/packages/switch/test/index.spec.js index d822b68f4..bbc2987d2 100644 --- a/packages/switch/test/index.spec.js +++ b/packages/switch/test/index.spec.js @@ -60,3 +60,15 @@ test('active-value & inactive-value prop', () => { expect(input).toHaveBeenCalledWith('2'); expect(change).toHaveBeenCalledWith('2'); }); + +test('inactive-color prop', () => { + const wrapper = mount(Switch, { + propsData: { + value: '2', + inactiveValue: '2', + inactiveColor: 'black' + } + }); + + expect(wrapper).toMatchSnapshot(); +});