react-native-ui-lib
Version:
<p align="center"> <img src="https://user-images.githubusercontent.com/1780255/105469025-56759000-5ca0-11eb-993d-3568c1fd54f4.png" height="250px" style="display:block"/> </p> <p align="center">UI Toolset & Components Library for React Native</p> <p a
37 lines (27 loc) • 1.4 kB
JavaScript
import baseComponent from '../baseComponent';
import {Colors} from '../../style';
const BaseComponent = baseComponent(false);
describe('BaseComponent', () => {
describe('updateModifiers', () => {
it('should update state with new modifiers values if modifiers props have changed', () => {
const uut = new BaseComponent({});
jest.spyOn(uut, 'setState');
uut.updateModifiers({someProp: true, 'bg-grey20': true}, {someProp: true, 'bg-grey30': true});
expect(uut.setState).toHaveBeenCalledWith({backgroundColor: Colors.grey30});
uut.updateModifiers({someProp: 'text'}, {'bg-red50': true, 'padding-20': true});
expect(uut.setState).toHaveBeenCalledWith({backgroundColor: Colors.red50, paddings: {padding: 20}});
});
it('should not update state if modifiers prop have not changed', () => {
const uut = new BaseComponent({});
jest.spyOn(uut, 'setState');
uut.updateModifiers({someProp: true, 'bg-grey20': true}, {someProp: false, 'bg-grey20': true});
expect(uut.setState).not.toHaveBeenCalled();
});
it('should not update state if any prop value has changed', () => {
const uut = new BaseComponent({});
jest.spyOn(uut, 'setState');
uut.updateModifiers({someProp: true, 'bg-grey20': true}, {someProp: true, 'bg-grey20': true});
expect(uut.setState).not.toHaveBeenCalled();
});
});
});