react-native-ui-lib
Version:
[](https://travis-ci.org/wix/react-native-ui-lib) [](https://www.npmjs.com/package/react-native-ui-lib) [![NPM Down
30 lines (27 loc) • 782 B
JavaScript
import TabBar from '../index';
describe('TabBar', () => {
describe('calcIndicatorWidth', () => {
it('should equale 25%', () => {
const uut = new TabBar({});
uut.itemsWidths = [80, 80, 80, 80];
uut.state = {
selectedIndex: 1,
};
uut.childrenCount = 4;
uut.contentWidth = 320;
jest.spyOn(uut, 'calcIndicatorWidth');
expect(uut.calcIndicatorWidth()).toEqual('25%');
});
it('should equale 50%', () => {
const uut = new TabBar({});
uut.itemsWidths = [150, 150, 300];
uut.state = {
selectedIndex: 2,
};
uut.childrenCount = 2;
uut.contentWidth = 600;
jest.spyOn(uut, 'calcIndicatorWidth');
expect(uut.calcIndicatorWidth()).toEqual('50%');
});
});
});