mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
update unit test mocks and restructure test dir structure
This commit is contained in:
1
__mocks__/fileMock.js
Normal file
1
__mocks__/fileMock.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module.exports = 'test-file-stub';
|
||||||
1
__mocks__/styleMock.js
Normal file
1
__mocks__/styleMock.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module.exports = {};
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow, mount } from 'enzyme';
|
import { shallow, mount } from 'enzyme';
|
||||||
import App from '../../src/App';
|
import App from '../src/App';
|
||||||
import api from '../../src/api';
|
import api from '../src/api';
|
||||||
import Dashboard from '../../src/pages/Dashboard';
|
import Dashboard from '../src/pages/Dashboard';
|
||||||
import Login from '../../src/pages/Login';
|
import Login from '../src/pages/Login';
|
||||||
|
|
||||||
describe('<App />', () => {
|
describe('<App />', () => {
|
||||||
test('renders without crashing', () => {
|
test('renders without crashing', () => {
|
||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
Redirect
|
Redirect
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import ConditionalRedirect from '../../src/components/ConditionalRedirect';
|
import ConditionalRedirect from '../src/components/ConditionalRedirect';
|
||||||
|
|
||||||
describe('<ConditionalRedirect />', () => {
|
describe('<ConditionalRedirect />', () => {
|
||||||
test('renders Redirect when shouldRedirect is passed truthy func', () => {
|
test('renders Redirect when shouldRedirect is passed truthy func', () => {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
import mockAxios from 'axios';
|
import mockAxios from 'axios';
|
||||||
import APIClient from '../../src/api';
|
import APIClient from '../src/api';
|
||||||
|
|
||||||
const API_ROOT = '/api/';
|
const API_ROOT = '/api/';
|
||||||
const API_LOGIN = `${API_ROOT}login/`;
|
const API_LOGIN = `${API_ROOT}login/`;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Applications from '../../../src/pages/Applications';
|
import Applications from '../../src/pages/Applications';
|
||||||
|
|
||||||
describe('<Applications />', () => {
|
describe('<Applications />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import AuthSettings from '../../../src/pages/AuthSettings';
|
import AuthSettings from '../../src/pages/AuthSettings';
|
||||||
|
|
||||||
describe('<AuthSettings />', () => {
|
describe('<AuthSettings />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import CredentialTypes from '../../../src/pages/CredentialTypes';
|
import CredentialTypes from '../../src/pages/CredentialTypes';
|
||||||
|
|
||||||
describe('<CredentialTypes />', () => {
|
describe('<CredentialTypes />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Credentials from '../../../src/pages/Credentials';
|
import Credentials from '../../src/pages/Credentials';
|
||||||
|
|
||||||
describe('<Credentials />', () => {
|
describe('<Credentials />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Dashboard from '../../../src/pages/Dashboard';
|
import Dashboard from '../../src/pages/Dashboard';
|
||||||
|
|
||||||
describe('<Dashboard />', () => {
|
describe('<Dashboard />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import InstanceGroups from '../../../src/pages/InstanceGroups';
|
import InstanceGroups from '../../src/pages/InstanceGroups';
|
||||||
|
|
||||||
describe('<InstanceGroups />', () => {
|
describe('<InstanceGroups />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Inventories from '../../../src/pages/Inventories';
|
import Inventories from '../../src/pages/Inventories';
|
||||||
|
|
||||||
describe('<Inventories />', () => {
|
describe('<Inventories />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import InventoryScripts from '../../../src/pages/InventoryScripts';
|
import InventoryScripts from '../../src/pages/InventoryScripts';
|
||||||
|
|
||||||
describe('<InventoryScripts />', () => {
|
describe('<InventoryScripts />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Jobs from '../../../src/pages/Jobs';
|
import Jobs from '../../src/pages/Jobs';
|
||||||
|
|
||||||
describe('<Jobs />', () => {
|
describe('<Jobs />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import JobsSettings from '../../../src/pages/JobsSettings';
|
import JobsSettings from '../../src/pages/JobsSettings';
|
||||||
|
|
||||||
describe('<JobsSettings />', () => {
|
describe('<JobsSettings />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import License from '../../../src/pages/License';
|
import License from '../../src/pages/License';
|
||||||
|
|
||||||
describe('<License />', () => {
|
describe('<License />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { mount, shallow } from 'enzyme';
|
import { mount, shallow } from 'enzyme';
|
||||||
import { asyncFlush } from '../../../jest.setup';
|
import { asyncFlush } from '../../jest.setup';
|
||||||
import LoginPage from '../../../src/pages/Login';
|
import LoginPage from '../../src/pages/Login';
|
||||||
import api from '../../../src/api';
|
import api from '../../src/api';
|
||||||
|
|
||||||
const LOGIN_ERROR_MESSAGE = 'Invalid username or password. Please try again.';
|
const LOGIN_ERROR_MESSAGE = 'Invalid username or password. Please try again.';
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import ManagementJobs from '../../../src/pages/ManagementJobs';
|
import ManagementJobs from '../../src/pages/ManagementJobs';
|
||||||
|
|
||||||
describe('<ManagementJobs />', () => {
|
describe('<ManagementJobs />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import NotificationTemplates from '../../../src/pages/NotificationTemplates';
|
import NotificationTemplates from '../../src/pages/NotificationTemplates';
|
||||||
|
|
||||||
describe('<NotificationTemplates />', () => {
|
describe('<NotificationTemplates />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Organizations from '../../../src/pages/Organizations';
|
import Organizations from '../../src/pages/Organizations';
|
||||||
|
|
||||||
describe('<Organizations />', () => {
|
describe('<Organizations />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Portal from '../../../src/pages/Portal';
|
import Portal from '../../src/pages/Portal';
|
||||||
|
|
||||||
describe('<Portal />', () => {
|
describe('<Portal />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Projects from '../../../src/pages/Projects';
|
import Projects from '../../src/pages/Projects';
|
||||||
|
|
||||||
describe('<Projects />', () => {
|
describe('<Projects />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Schedules from '../../../src/pages/Schedules';
|
import Schedules from '../../src/pages/Schedules';
|
||||||
|
|
||||||
describe('<Schedules />', () => {
|
describe('<Schedules />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import SystemSettings from '../../../src/pages/SystemSettings';
|
import SystemSettings from '../../src/pages/SystemSettings';
|
||||||
|
|
||||||
describe('<SystemSettings />', () => {
|
describe('<SystemSettings />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Teams from '../../../src/pages/Teams';
|
import Teams from '../../src/pages/Teams';
|
||||||
|
|
||||||
describe('<Teams />', () => {
|
describe('<Teams />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Templates from '../../../src/pages/Templates';
|
import Templates from '../../src/pages/Templates';
|
||||||
|
|
||||||
describe('<Templates />', () => {
|
describe('<Templates />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import UISettings from '../../../src/pages/UISettings';
|
import UISettings from '../../src/pages/UISettings';
|
||||||
|
|
||||||
describe('<UISettings />', () => {
|
describe('<UISettings />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import Users from '../../../src/pages/Users';
|
import Users from '../../src/pages/Users';
|
||||||
|
|
||||||
describe('<Users />', () => {
|
describe('<Users />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports = 'svg-stub';
|
|
||||||
@@ -3,11 +3,12 @@ module.exports = {
|
|||||||
'src/**/*.{js,jsx}'
|
'src/**/*.{js,jsx}'
|
||||||
],
|
],
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'^[./a-zA-Z0-9$_-]+\\.svg$': '<rootDir>/__tests__/stubs/svgStub.js'
|
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
|
||||||
|
'\\.(css|scss|less)$': '<rootDir>/__mocks__/styleMock.js'
|
||||||
},
|
},
|
||||||
setupTestFrameworkScriptFile: '<rootDir>/jest.setup.js',
|
setupTestFrameworkScriptFile: '<rootDir>/jest.setup.js',
|
||||||
testMatch: [
|
testMatch: [
|
||||||
'<rootDir>/__tests__/tests/**/*.{js,jsx}'
|
'<rootDir>/__tests__/**/*.{js,jsx}'
|
||||||
],
|
],
|
||||||
testEnvironment: 'jsdom',
|
testEnvironment: 'jsdom',
|
||||||
testURL: 'http://127.0.0.1:3001',
|
testURL: 'http://127.0.0.1:3001',
|
||||||
|
|||||||
Reference in New Issue
Block a user