mattermost-mobile/app/components/fade.test.js
Elias Nahum f36ee37402
Upgrade to RN 0.59.6 and dependencies (#2777)
* Upgrade to RN 0.59.6 and dependencies

* Remove channel loader unused style

* Update to the latest netInfo that fixes a crash

* Do not set default timezone with moment

* Use RN 0.59.8
2019-05-13 13:33:18 -04:00

60 lines
1.7 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Animated, Text} from 'react-native';
import {shallow} from 'enzyme';
import Fade from './fade';
jest.useFakeTimers();
describe('Fade', () => {
const baseProps = {
visible: true,
disabled: true,
};
function getWrapper(props = {}) {
const dummyText = 'text';
return shallow(
<Fade
{...baseProps}
{...props}
>
<Text>{dummyText}</Text>
</Fade>
);
}
test('should render {opacity: 1}', () => {
const wrapper = getWrapper({visible: true});
expect(wrapper.getElement()).toMatchSnapshot();
expect(wrapper).toHaveStyle('opacity', new Animated.Value(1));
});
test('should render {opacity: 0}', () => {
const wrapper = getWrapper({visible: false});
expect(wrapper.getElement()).toMatchSnapshot();
expect(wrapper).toHaveStyle('opacity', new Animated.Value(0));
});
test('should not change opacity when disabled flag is switched', () => {
const wrapper = getWrapper({disabled: false});
expect(wrapper).toHaveStyle('opacity', new Animated.Value(1));
wrapper.setProps({disabled: true});
expect(wrapper).toHaveStyle('opacity', new Animated.Value(1));
});
test('should not change opacity when props stay the same', () => {
const wrapper = getWrapper({visible: true});
expect(wrapper).toHaveStyle('opacity', new Animated.Value(1));
wrapper.setProps({visible: true});
expect(wrapper).toHaveStyle('opacity', new Animated.Value(1));
});
});