mirror of
https://github.com/ansible/awx.git
synced 2026-02-15 02:00:01 -03:30
move ConditionalRedirect test to components subfolder
This commit is contained in:
35
__tests__/components/ConditionalRedirect.test.jsx
Normal file
35
__tests__/components/ConditionalRedirect.test.jsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Route,
|
||||
Redirect
|
||||
} from 'react-router-dom';
|
||||
import { shallow } from 'enzyme';
|
||||
import ConditionalRedirect from '../../src/components/ConditionalRedirect';
|
||||
|
||||
describe('<ConditionalRedirect />', () => {
|
||||
test('renders Redirect when shouldRedirect is passed truthy func', () => {
|
||||
const truthyFunc = () => true;
|
||||
const shouldHaveRedirectChild = shallow(
|
||||
<ConditionalRedirect
|
||||
shouldRedirect={() => truthyFunc()}
|
||||
/>
|
||||
);
|
||||
const redirectChild = shouldHaveRedirectChild.find(Redirect);
|
||||
expect(redirectChild.length).toBe(1);
|
||||
const routeChild = shouldHaveRedirectChild.find(Route);
|
||||
expect(routeChild.length).toBe(0);
|
||||
});
|
||||
|
||||
test('renders Route when shouldRedirect is passed falsy func', () => {
|
||||
const falsyFunc = () => false;
|
||||
const shouldHaveRouteChild = shallow(
|
||||
<ConditionalRedirect
|
||||
shouldRedirect={() => falsyFunc()}
|
||||
/>
|
||||
);
|
||||
const routeChild = shouldHaveRouteChild.find(Route);
|
||||
expect(routeChild.length).toBe(1);
|
||||
const redirectChild = shouldHaveRouteChild.find(Redirect);
|
||||
expect(redirectChild.length).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user