chore: relocate unit test (#39)

add new json snapshot serializer
This commit is contained in:
Juan Picado @jotadeveloper 2019-05-01 21:02:46 +02:00 committed by Ayush Sharma
parent 1070e5c3aa
commit 9d7be476ad
35 changed files with 38 additions and 34 deletions

View File

@ -6,7 +6,7 @@ module.exports = {
collectCoverage: true,
testEnvironment: 'jest-environment-jsdom-global',
testURL: 'http://localhost',
testRegex: '(test/unit/webui/.*\\.spec)\\.js',
testRegex: '(test/unit/.*\\.spec)\\.js',
setupFiles: [
'./test/unit/setup.js'
],
@ -35,6 +35,7 @@ module.exports = {
'<rootDir>/build',
],
snapshotSerializers: [
'enzyme-to-json/serializer',
"jest-emotion"
],
coveragePathIgnorePatterns: [

View File

@ -28,6 +28,7 @@
"emotion": "9.2.12",
"enzyme": "3.9.0",
"enzyme-adapter-react-16": "1.10.0",
"enzyme-to-json": "3.3.5",
"eslint": "5.14.1",
"eslint-config-google": "0.12.0",
"eslint-config-prettier": "4.1.0",

View File

@ -1,5 +0,0 @@
import path from 'path';
export const parseConfigurationFile = (name) => {
return path.join(__dirname, `./partials/config/yaml/${name}.yaml`);
};

View File

@ -1,11 +1,11 @@
import React from 'react';
import { mount } from 'enzyme';
import storage from '../../../src/webui/utils/storage';
import App from '../../../src/webui/app';
import storage from '../../src/webui/utils/storage';
import App from '../../src/webui/app';
import { generateTokenWithTimeRange } from './components/__mocks__/token';
jest.mock('../../../src/webui/utils/storage', () => {
jest.mock('../../src/webui/utils/storage', () => {
class LocalStorageMock {
constructor() {
this.store = {};
@ -26,7 +26,7 @@ jest.mock('../../../src/webui/utils/storage', () => {
return new LocalStorageMock();
});
jest.mock('../../../src/webui/utils/api', () => ({
jest.mock('../../src/webui/utils/api', () => ({
request: require('./components/__mocks__/api').default.request
}));

View File

@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<NotFound /> component should load the component in default state 1`] = `ShallowWrapper {}`;
exports[`<NotFound /> component should load the component in default state 1`] = `<withRouter(WithTheme(WithWidth(NotFound))) />`;

View File

@ -6,8 +6,8 @@
import React from 'react';
import { shallow } from 'enzyme';
import CopyToClipBoard from '../../../../src/webui/components/CopyToClipBoard';
import { CopyIcon } from '../../../../src/webui/components/CopyToClipBoard/styles';
import CopyToClipBoard from '../../../src/webui/components/CopyToClipBoard/index';
import { CopyIcon } from '../../../src/webui/components/CopyToClipBoard/styles';
describe('<CopyToClipBoard /> component', () => {
let wrapper;

View File

@ -2,9 +2,9 @@
import React from 'react';
import { mount } from 'enzyme';
import Footer from '../../../../src/webui/components/Footer/index';
import Footer from '../../../src/webui/components/Footer/index';
jest.mock('../../../../package.json', () => ({
jest.mock('../../../package.json', () => ({
version: '4.0.0-alpha.3'
}));

View File

@ -6,7 +6,7 @@
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { shallow } from 'enzyme';
import Header from '../../../../src/webui/components/Header';
import Header from '../../../src/webui/components/Header/index';
describe('<Header /> component with logged in state', () => {
let wrapper;

View File

@ -3,7 +3,7 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import Help from '../../../../src/webui/components/Help/index';
import Help from '../../../src/webui/components/Help/index';
describe('<Help /> component', () => {

View File

@ -6,7 +6,7 @@
import React from 'react';
import { mount } from 'enzyme';
import LoginModal from '../../../../src/webui/components/Login';
import LoginModal from '../../../src/webui/components/Login/index';
const eventUsername = {
target: {

View File

@ -4,7 +4,7 @@
import React from 'react';
import { shallow, mount } from 'enzyme';
import NoItems from '../../../../src/webui/components/NoItems/index';
import NoItems from '../../../src/webui/components/NoItems/index';
console.error = jest.fn();

View File

@ -5,7 +5,7 @@
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { shallow } from 'enzyme';
import NotFound from '../../../../src/webui/components/NotFound/index';
import NotFound from '../../../src/webui/components/NotFound/index';
console.error = jest.fn();

View File

@ -4,9 +4,9 @@
import React from 'react';
import { shallow } from 'enzyme';
import Package from '../../../../src/webui/components/Package/index';
import Tag from '../../../../src/webui/components/Tag/index';
import { Version, WrapperLink, Field, OverviewItem } from '../../../../src/webui/components/Package/styles';
import Package from '../../../src/webui/components/Package/index';
import Tag from '../../../src/webui/components/Tag/index';
import { Version, WrapperLink, Field, OverviewItem } from '../../../src/webui/components/Package/styles';
/**

View File

@ -4,8 +4,8 @@
import React from 'react';
import { mount } from 'enzyme';
import PackageList from '../../../../src/webui/components/PackageList/index';
import Help from '../../../../src/webui/components/Help/index';
import PackageList from '../../../src/webui/components/PackageList/index';
import Help from '../../../src/webui/components/Help/index';
import { BrowserRouter } from 'react-router-dom';
describe('<PackageList /> component', () => {

View File

@ -4,7 +4,7 @@
import React from 'react';
import { shallow, mount } from 'enzyme';
import Readme from '../../../../src/webui/components/Readme/index';
import Readme from '../../../src/webui/components/Readme/index';
describe('<Readme /> component', () => {
test('should load the component in default state', () => {

View File

@ -6,11 +6,11 @@
import React from 'react';
import { mount } from 'enzyme';
import { Search } from '../../../../src/webui/components/Search/index';
import { Search } from '../../../src/webui/components/Search/index';
const SEARCH_FILE_PATH = '../../../../src/webui/components/Search/index';
const API_FILE_PATH = '../../../../src/webui/utils/api';
const URL_FILE_PATH = '../../../../src/webui/utils/url';
const SEARCH_FILE_PATH = '../../../src/webui/components/Search/index';
const API_FILE_PATH = '../../../src/webui/utils/api';
const URL_FILE_PATH = '../../../src/webui/utils/url';
// Global mocks
const event = {

View File

@ -1,4 +1,4 @@
import {API_ERROR} from '../../../../../src/lib/constants';
import {API_ERROR} from '../../../../src/lib/constants';
/**
* API mock for login endpoint
* @param {object} config configuration of api call

View File

@ -1,4 +1,4 @@
import { isTokenExpire, makeLogin } from '../../../../src/webui/utils/login';
import { isTokenExpire, makeLogin } from '../../../src/webui/utils/login';
import {
generateTokenWithTimeRange,

View File

@ -5,7 +5,7 @@ import {
formatDateDistance,
getLastUpdatedPackageTime,
getRecentReleases
} from '../../../../src/webui/utils/package';
} from '../../../src/webui/utils/package';
import { packageMeta } from '../components/store/packageMeta';

View File

@ -4771,6 +4771,13 @@ enzyme-adapter-utils@^1.10.0:
prop-types "^15.7.2"
semver "^5.6.0"
enzyme-to-json@3.3.5:
version "3.3.5"
resolved "https://registry.verdaccio.org/enzyme-to-json/-/enzyme-to-json-3.3.5.tgz#f8eb82bd3d5941c9d8bc6fd9140030777d17d0af"
integrity sha512-DmH1wJ68HyPqKSYXdQqB33ZotwfUhwQZW3IGXaNXgR69Iodaoj8TF/D9RjLdz4pEhGq2Tx2zwNUIjBuqoZeTgA==
dependencies:
lodash "^4.17.4"
enzyme@3.9.0:
version "3.9.0"
resolved "https://registry.npmjs.org/enzyme/-/enzyme-3.9.0.tgz#2b491f06ca966eb56b6510068c7894a7e0be3909"