Unverified Commit 2825dd74 authored by Marcos Iglesias's avatar Marcos Iglesias Committed by GitHub

chore: Removes 84 unused variables (#600)

Signed-off-by: 's avatarMarcos Iglesias Valle <golodhros@gmail.com>
parent 30807312
......@@ -29,7 +29,7 @@ describe('ImagePreview', () => {
describe('onSuccess', () => {
let currentState;
beforeAll(() => {
const { props, wrapper } = setup();
const { wrapper } = setup();
wrapper.instance().onSuccess();
currentState = wrapper.state();
});
......@@ -44,7 +44,7 @@ describe('ImagePreview', () => {
describe('onError', () => {
let currentState;
beforeAll(() => {
const { props, wrapper } = setup();
const { wrapper } = setup();
const event = {} as React.SyntheticEvent<HTMLImageElement>;
wrapper.instance().onError(event);
currentState = wrapper.state();
......@@ -111,7 +111,7 @@ describe('ImagePreview', () => {
describe('when there is an error', () => {
it('renders a link', () => {
const { props, wrapper } = setup();
const { wrapper } = setup();
wrapper.instance().setState({ hasError: true });
wrapper.update();
......
......@@ -6,7 +6,7 @@ import { OverlayTrigger, Popover } from 'react-bootstrap';
import { ResourceType } from 'interfaces';
import { getSourceDisplayName, getSourceIconClass } from 'config/config-utils';
import { getSourceDisplayName } from 'config/config-utils';
import './styles.scss';
......@@ -24,7 +24,6 @@ type GoToDashboardLinkProps = {
const QUERY_LABEL = 'Query';
const LINK_TOOLTIP_TEXT = 'View in';
const LOADING_QUERY_MESSAGE = 'Loading Query Component, please wait...';
const LazyComponent = React.lazy(() => import('./CodeBlock'));
......
......@@ -7,7 +7,6 @@ import * as History from 'history';
import { shallow } from 'enzyme';
import AvatarLabel from 'components/common/AvatarLabel';
import LoadingSpinner from 'components/common/LoadingSpinner';
import Breadcrumb from 'components/common/Breadcrumb';
import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon';
......@@ -16,7 +15,6 @@ import ResourceList from 'components/common/ResourceList';
import TabsComponent from 'components/common/TabsComponent';
import { dashboardMetadata } from 'fixtures/metadata/dashboard';
import { NO_TIMESTAMP_TEXT } from 'components/constants';
import * as LogUtils from 'utils/logUtils';
import { ResourceType } from 'interfaces';
import { BadgeStyle } from 'config/config-types';
import ChartList from './ChartList';
......
......@@ -9,13 +9,7 @@ import BugReportFeedbackForm from './FeedbackForm/BugReportFeedbackForm';
import RatingFeedbackForm from './FeedbackForm/RatingFeedbackForm';
import RequestFeedbackForm from './FeedbackForm/RequestFeedbackForm';
import Feedback, { FeedbackProps, FeedbackType } from '.';
import {
BUG_REPORT_TEXT,
BUTTON_CLOSE_TEXT,
FEEDBACK_TYPE_TEXT,
RATING_TEXT,
REQUEST_TEXT,
} from './constants';
import { BUG_REPORT_TEXT, RATING_TEXT, REQUEST_TEXT } from './constants';
describe('Feedback', () => {
const setStateSpy = jest.spyOn(Feedback.prototype, 'setState');
......@@ -29,13 +23,13 @@ describe('Feedback', () => {
};
describe('constructor', () => {
let props;
let wrapper;
beforeAll(() => {
const setupResult = setup();
props = setupResult.props;
wrapper = setupResult.wrapper;
});
it('sets state.isOpen to false', () => {
expect(wrapper.state().isOpen).toEqual(false);
});
......@@ -52,22 +46,24 @@ describe('Feedback', () => {
describe('toggle', () => {
it('calls setState with negation of state.isOpen', () => {
setStateSpy.mockClear();
const { props, wrapper } = setup();
const { wrapper } = setup();
const previsOpenState = wrapper.state().isOpen;
wrapper.instance().toggle();
expect(setStateSpy).toHaveBeenCalledWith({ isOpen: !previsOpenState });
});
});
describe('changeType', () => {
let props;
let wrapper;
beforeAll(() => {
const setupResult = setup();
props = setupResult.props;
wrapper = setupResult.wrapper;
setStateSpy.mockClear();
});
it('returns method that calls setState with correct values if type === FeedbackType.Bug', () => {
wrapper.instance().changeType(FeedbackType.Bug)();
expect(setStateSpy).toHaveBeenCalledWith({
......@@ -99,9 +95,9 @@ describe('Feedback', () => {
let feedbackComponent;
let props;
let wrapper;
let changeTypeSpy;
let changeTypeMockResult;
beforeAll(() => {
const setupResult = setup({ title: 'I am a title' });
props = setupResult.props;
......@@ -116,6 +112,7 @@ describe('Feedback', () => {
feedbackIcon = wrapper.children().at(0);
feedbackComponent = wrapper.children().at(1);
});
it('renders help button with correct props', () => {
expect(feedbackIcon.exists()).toBe(true);
expect(feedbackIcon.props().className).toEqual(
......@@ -322,13 +319,13 @@ describe('Feedback', () => {
});
describe('if !state.isOpen', () => {
let props;
let wrapper;
beforeAll(() => {
const setupResult = setup();
props = setupResult.props;
wrapper = setupResult.wrapper;
});
it('renders help button with correct props', () => {
const feedbackIcon = wrapper.children().at(0);
expect(feedbackIcon.exists()).toBe(true);
......
......@@ -77,18 +77,21 @@ describe('ExploreButton', () => {
it('returns null if explore is not enabled', () => {
mockExploreEnabled = false;
const { props, wrapper } = setup();
const { wrapper } = setup();
expect(wrapper.instance().render()).toBeNull();
});
it('returns null if the generated url is empty', () => {
const { props, wrapper } = setup();
const { wrapper } = setup();
mockExploreUrl = '';
expect(wrapper.instance().render()).toBeNull();
});
it('renders a link to the explore URL', () => {
const { props, wrapper } = setup();
const { wrapper } = setup();
expect(wrapper.find('a').props()).toMatchObject({
href: mockExploreUrl,
target: '_blank',
......
......@@ -5,7 +5,6 @@ import * as React from 'react';
import { shallow } from 'enzyme';
import { ResourceReport } from 'interfaces/TableMetadata';
import { logClick } from 'ducks/utilMethods';
import TableReportsDropdown from '.';
describe('TableReportsDropdown component', () => {
......@@ -27,6 +26,7 @@ describe('TableReportsDropdown component', () => {
const container = tableReportsDropdown.find('DropdownMenu');
expect(container.exists()).toBe(true);
});
it('do not render resource reports', () => {
const container = shallow(
<TableReportsDropdown resourceReports={[]} />
......
......@@ -21,7 +21,7 @@ const TableReportsDropdown: React.FC<ResourceReportProps> = ({
</Dropdown.Toggle>
<Dropdown.Menu className="profile-menu">
{resourceReports.map((report) => (
<li>
<li key={report.url}>
<a target="_blank" rel="noreferrer" href={`${report.url}`}>
{`${report.name}`}
</a>
......
......@@ -37,7 +37,7 @@ describe('BookmarkIcon', () => {
stopPropagation: jest.fn(),
};
it('stops propagation and prevents default', () => {
const { props, wrapper } = setup();
const { wrapper } = setup();
wrapper.find('div').simulate('click', clickEvent);
expect(clickEvent.preventDefault).toHaveBeenCalled();
expect(clickEvent.stopPropagation).toHaveBeenCalled();
......@@ -69,17 +69,17 @@ describe('BookmarkIcon', () => {
describe('render', () => {
it('renders an empty bookmark when not bookmarked', () => {
const { props, wrapper } = setup({ isBookmarked: false });
const { wrapper } = setup({ isBookmarked: false });
expect(wrapper.find('.icon-bookmark').exists()).toBe(true);
});
it('renders a filled star when bookmarked', () => {
const { props, wrapper } = setup({ isBookmarked: true });
const { wrapper } = setup({ isBookmarked: true });
expect(wrapper.find('.icon-bookmark-filled').exists()).toBe(true);
});
it('renders a large star when specified', () => {
const { props, wrapper } = setup({ large: true });
const { wrapper } = setup({ large: true });
expect(wrapper.find('.bookmark-large').exists()).toBe(true);
});
});
......
......@@ -8,7 +8,7 @@ import { shallow } from 'enzyme';
import { Link } from 'react-router-dom';
import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon';
import SchemaInfo from 'components/common/ResourceListItem/SchemaInfo';
import { ResourceType, Badge, TagType } from 'interfaces';
import { ResourceType, TagType } from 'interfaces';
import * as ConfigUtils from 'config/config-utils';
import BadgeList from 'components/common/BadgeList';
......@@ -68,9 +68,8 @@ describe('TableListItem', () => {
it('calls getSourceIconClass with given database id', () => {
const testValue = 'noEffectOnTest';
const givenResource = ResourceType.table;
const iconClass = wrapper
.instance()
.generateResourceIconClass(testValue, givenResource);
wrapper.instance().generateResourceIconClass(testValue, givenResource);
expect(getDBIconClassSpy).toHaveBeenCalledWith(testValue, givenResource);
});
......@@ -129,7 +128,7 @@ describe('TableListItem', () => {
describe('if props.table not have schema description', () => {
it('if schema description is empty string', () => {
const { props, wrapper } = setup({
const { wrapper } = setup({
table: {
type: ResourceType.table,
cluster: '',
......@@ -149,7 +148,7 @@ describe('TableListItem', () => {
});
it('if schema description is null', () => {
const { props, wrapper } = setup({
const { wrapper } = setup({
table: {
type: ResourceType.table,
cluster: '',
......@@ -221,7 +220,7 @@ describe('TableListItem', () => {
describe('if props.table does not have badges', () => {
it('does not render badges section', () => {
const { props, wrapper } = setup({
const { wrapper } = setup({
table: {
type: ResourceType.table,
cluster: '',
......@@ -238,7 +237,7 @@ describe('TableListItem', () => {
});
it('or if they are empty does not render badges section', () => {
const { props, wrapper } = setup({
const { wrapper } = setup({
table: {
type: ResourceType.table,
cluster: '',
......
......@@ -19,7 +19,6 @@ import {
noResultsExample,
} from 'fixtures/search/inlineResults';
import { logClick } from 'ducks/utilMethods';
import { SearchItem, SearchItemProps, mapStateToProps } from '..';
jest.mock('ducks/utilMethods', () => ({
......@@ -52,7 +51,7 @@ describe('SearchItem', () => {
describe('renderIndicator', () => {
it('renders LoadingSpinner if props.isLoading', () => {
const { props, wrapper } = setup({ isLoading: true });
const { wrapper } = setup({ isLoading: true });
const content = shallow(
<div>{wrapper.instance().renderIndicator()}</div>
);
......@@ -60,13 +59,13 @@ describe('SearchItem', () => {
});
it('renders correct text if !props.hasResults', () => {
const { props, wrapper } = setup({ hasResults: false });
const { wrapper } = setup({ hasResults: false });
const content = shallow(wrapper.instance().renderIndicator());
expect(content.text()).toBe(SEARCH_ITEM_NO_RESULTS);
});
it('renders nothing if !props.Loading and props.hasResults', () => {
const { props, wrapper } = setup({ isLoading: false, hasResults: true });
const { wrapper } = setup({ isLoading: false, hasResults: true });
expect(wrapper.instance().renderIndicator()).toBe(null);
});
});
......
......@@ -98,8 +98,10 @@ export class SearchBar extends React.Component<SearchBarProps, SearchBarState> {
};
componentDidUpdate = (prevProps: SearchBarProps) => {
if (this.props.searchTerm !== prevProps.searchTerm) {
this.setState({ searchTerm: this.props.searchTerm });
const { searchTerm } = this.props;
if (searchTerm !== prevProps.searchTerm) {
this.setState({ searchTerm });
}
};
......@@ -121,8 +123,11 @@ export class SearchBar extends React.Component<SearchBarProps, SearchBarState> {
handleValueSubmit = (event: React.FormEvent<HTMLFormElement>): void => {
const searchTerm = this.state.searchTerm.trim();
event.preventDefault();
if (this.isFormValid(searchTerm)) {
this.props.submitSearch(searchTerm);
const { submitSearch } = this.props;
submitSearch(searchTerm);
this.hideTypeAhead();
}
};
......
......@@ -22,7 +22,6 @@ describe('dashboard reducer', () => {
});
it('should handle GetDashboard.REQUEST', () => {
const term = 'testSearch';
expect(reducer(testState, getDashboard({ uri: 'testUri' }))).toEqual({
...testState,
isLoading: true,
......
import axios, { AxiosResponse } from 'axios';
import axios from 'axios';
import { NotificationType } from 'interfaces';
import AppConfig from 'config/config';
import * as API from '../v0';
......@@ -26,7 +26,7 @@ describe('getIssues', () => {
it('calls axios with correct parameters if tableKey provided', async () => {
expect.assertions(1);
await API.getIssues('tableKey').then((data) => {
await API.getIssues('tableKey').then(() => {
expect(axiosMock).toHaveBeenCalledWith(
`${API.API_PATH}/issues?key=tableKey`
);
......@@ -35,6 +35,7 @@ describe('getIssues', () => {
it('returns response data', async () => {
expect.assertions(1);
await API.getIssues('tableKey').then((data) => {
expect(data).toEqual(mockGetResponse.data.issues);
});
......
import axios, { AxiosResponse, AxiosError } from 'axios';
import axios, { AxiosResponse } from 'axios';
export const API_PATH = '/api/metadata/v0';
......@@ -14,7 +14,7 @@ export function getLastIndexed() {
return data.timestamp;
})
.catch((e) => {
.catch(() => {
const timestamp = null;
return Promise.reject({
timestamp,
......
import axios, { AxiosResponse } from 'axios';
import {
DashboardSearchResults,
TableSearchResults,
UserSearchResults,
} from 'ducks/search/types';
import globalState from 'fixtures/globalState';
import { ResourceType, SearchType } from 'interfaces';
......
......@@ -7,7 +7,7 @@ import reducer, {
initialFilterState,
FilterReducerState,
UpdateSearchFilter,
} from '../reducer';
} from './reducer';
describe('filters reducer', () => {
describe('actions', () => {
......@@ -57,8 +57,6 @@ describe('filters reducer', () => {
});
it('does not update the filter state if request does not contains filter information', () => {
const givenResource = ResourceType.table;
const givenFilters = { database: { testDb: true } };
const result = reducer(
testState,
submitSearchResource({
......
......@@ -7,10 +7,10 @@ import * as SearchUtils from 'ducks/search/utils';
import globalState from 'fixtures/globalState';
import { datasetFilterExample } from 'fixtures/search/filters';
import { ResourceType, SearchType } from 'interfaces';
import { SearchType } from 'interfaces';
import { updateFilterByCategory, UpdateSearchFilter } from '../reducer';
import * as Sagas from '../sagas';
import { updateFilterByCategory, UpdateSearchFilter } from './reducer';
import * as Sagas from './sagas';
describe('filter sagas', () => {
describe('filterWatcher', () => {
......
import { ResourceType, SearchType } from 'interfaces';
import * as NavigationUtils from 'utils/navigationUtils';
import * as SearchUtils from 'ducks/search/utils';
import globalState from 'fixtures/globalState';
import * as API from '../api/v0';
import * as filterReducer from '../filters/reducer';
import * as filterReducer from './filters/reducer';
import reducer, {
getInlineResults,
......@@ -30,7 +28,7 @@ import reducer, {
updateFromInlineResult,
updateSearchState,
urlDidUpdate,
} from '../reducer';
} from './reducer';
import {
LoadPreviousSearch,
InlineSearch,
......@@ -42,7 +40,7 @@ import {
SearchResponsePayload,
SubmitSearch,
UrlDidUpdate,
} from '../types';
} from './types';
const MOCK_TABLE_FILTER_STATE = { database: { hive: true } };
const MOCK_FILTER_STATE = {
......@@ -52,7 +50,7 @@ const filterReducerSpy = jest
.spyOn(filterReducer, 'default')
.mockImplementation(() => MOCK_FILTER_STATE);
const updateSearchUrlSpy = jest.spyOn(NavigationUtils, 'updateSearchUrl');
jest.spyOn(NavigationUtils, 'updateSearchUrl');
const searchState = globalState.search;
describe('search reducer', () => {
......@@ -492,7 +490,8 @@ describe('search reducer', () => {
it('calls filter reducer with existing filters', () => {
filterReducerSpy.mockClear();
const result = reducer(initialState, filterAction);
reducer(initialState, filterAction);
expect(filterReducerSpy).toHaveBeenCalledWith(
initialState.filters,
filterAction
......
......@@ -18,7 +18,6 @@ import * as API from './api/v0';
import {
LoadPreviousSearch,
LoadPreviousSearchRequest,
SearchAll,
SearchAllRequest,
SearchResource,
......@@ -45,14 +44,13 @@ import {
searchResourceFailure,
searchResourceSuccess,
getInlineResults,
getInlineResultsDebounce,
getInlineResultsSuccess,
getInlineResultsFailure,
updateFromInlineResult,
updateSearchState,
submitSearchResource,
} from './reducer';
import { initialFilterState, UpdateSearchFilter } from './filters/reducer';
import { initialFilterState } from './filters/reducer';
import { autoSelectResource, getPageIndex, getSearchState } from './utils';
// SEARCH SAGAS
......@@ -194,9 +192,7 @@ export function* urlDidUpdateWatcher(): SagaIterator {
* Handles workflow for user actions on navigations components.
* Leverages BrowserHistory or updates search url accordingly.
*/
export function* loadPreviousSearchWorker(
action: LoadPreviousSearchRequest
): SagaIterator {
export function* loadPreviousSearchWorker(): SagaIterator {
const state = yield select(getSearchState);
if (state.search_term === '') {
BrowserHistory.goBack();
......
import { testSaga } from 'redux-saga-test-plan';
import { debounce } from 'redux-saga/effects';
import { DEFAULT_RESOURCE_TYPE, ResourceType, SearchType } from 'interfaces';
import { ResourceType, SearchType } from 'interfaces';
import * as NavigationUtils from 'utils/navigationUtils';
import * as SearchUtils from 'ducks/search/utils';
......@@ -11,30 +10,20 @@ import * as API from '../api/v0';
import * as Sagas from '../sagas';
import {
initialState,
initialInlineResultsState,
loadPreviousSearch,
searchAll,
searchAllFailure,
searchAllSuccess,
SearchReducerState,
searchResource,
searchResourceFailure,
searchResourceSuccess,
selectInlineResult,
submitSearch,
submitSearchResource,
updateFromInlineResult,
updateSearchState,
urlDidUpdate,
} from '../reducer';
import {
LoadPreviousSearch,
InlineSearch,
InlineSearchResponsePayload,
InlineSearchUpdatePayload,
SearchAll,
SearchAllResponsePayload,
SearchResource,
SearchResponsePayload,
SubmitSearch,
......@@ -225,7 +214,7 @@ describe('search sagas', () => {
searchType: SearchType.FILTER,
resourceFilters: { database: { hive: true } },
});
const { search_term, resource } = searchState;
const { resource } = searchState;
testSaga(Sagas.submitSearchResourceWorker, filterAction)
.next()
.select(SearchUtils.getSearchState)
......@@ -243,7 +232,7 @@ describe('search sagas', () => {
resourceFilters: { database: { hive: true } },
resource: ResourceType.table,
});
const { search_term, resource } = searchState;
testSaga(Sagas.submitSearchResourceWorker, filterAction)
.next()
.select(SearchUtils.getSearchState)
......@@ -271,7 +260,7 @@ describe('search sagas', () => {
it('it update url if necessary with existing state values', () => {
updateSearchUrlSpy.mockClear();
const action = updateSearchState({ updateUrl: true });
const { search_term, resource } = searchState;
testSaga(Sagas.updateSearchStateWorker, action)
.next()
.select(SearchUtils.getSearchState)
......@@ -291,7 +280,7 @@ describe('search sagas', () => {
filters: { [ResourceType.table]: { database: { bigquery: true } } },
submitSearch: true,
});
const { search_term, resource } = searchState;
testSaga(Sagas.updateSearchStateWorker, action)
.next()
.select(SearchUtils.getSearchState)
......@@ -417,7 +406,7 @@ describe('search sagas', () => {
it('applies the existing search state into the URL', () => {
updateSearchUrlSpy.mockClear();
testSaga(Sagas.loadPreviousSearchWorker, loadPreviousSearch())
testSaga(Sagas.loadPreviousSearchWorker)
.next()
.select(SearchUtils.getSearchState)
.next(searchState)
......
import axios from 'axios';
import * as qs from 'simple-query-string';
import * as Utils from 'ducks/utilMethods';
import globalState from 'fixtures/globalState';
import { relatedDashboards } from 'fixtures/metadata/table';
import { NotificationType, UpdateMethod, UpdateOwnerPayload } from 'interfaces';
import { NotificationType, UpdateMethod } from 'interfaces';
import * as Helpers from './helpers';
import * as API from './v0';
......@@ -17,7 +15,6 @@ jest.mock('axios');
describe('helpers', () => {
let mockResponseData: API.TableDataAPI;
let mockRelatedDashboardsResponseData: API.RelatedDashboardDataAPI;
let tableResponseData: API.TableData;
beforeAll(() => {
tableResponseData = {
......@@ -35,10 +32,6 @@ describe('helpers', () => {
{ tag_count: 1, tag_name: 'aname' },
],
};
mockRelatedDashboardsResponseData = {
dashboards: relatedDashboards,
msg: '',
};
mockResponseData = {
tableData: tableResponseData,
msg: 'Success',
......
import * as qs from 'simple-query-string';
import { filterFromObj, sortTagsAlphabetical } from 'ducks/utilMethods';
import { filterFromObj } from 'ducks/utilMethods';
import {
NotificationType,
OwnerDict,
PeopleUser,
TableMetadata,
Tag,
UpdateMethod,
UpdateOwnerPayload,
User,
......
......@@ -77,7 +77,7 @@ export function getTableDashboards(tableKey: string) {
if (response && response.data && response.data.msg) {
msg = response.data.msg;
}
const status = response ? response.status : null;
return Promise.reject({ msg, dashboards: [] });
});
}
......@@ -126,7 +126,7 @@ export function generateOwnerUpdateRequests(
/* Chain requests to send notification on success to desired users */
const request = axios(updatePayload)
.then((response) => {
.then(() => {
return axios.get(`/api/metadata/v0/user?user_id=${item.id}`);
})
.then((response) => {
......
......@@ -5,15 +5,13 @@ import {
PreviewQueryParams,
TableMetadata,
Tag,
UpdateMethod,
UpdateOwnerPayload,
User,
} from 'interfaces';
import { dashboardSummary } from 'fixtures/metadata/dashboard';
import globalState from 'fixtures/globalState';
import * as API from '../api/v0';
import * as API from './api/v0';
import reducer, {
getTableData,
......@@ -31,11 +29,10 @@ import reducer, {
getPreviewData,
getPreviewDataFailure,
getPreviewDataSuccess,
initialPreviewState,
initialTableDataState,
initialState,
TableMetadataReducerState,
} from '../reducer';
} from './reducer';
import {
getTableDataWatcher,
......@@ -50,7 +47,7 @@ import {
updateColumnDescriptionWorker,
getPreviewDataWatcher,
getPreviewDataWorker,
} from '../sagas';
} from './sagas';
import {
GetTableData,
......@@ -59,7 +56,7 @@ import {
GetColumnDescription,
UpdateColumnDescription,
GetPreviewData,
} from '../types';
} from './types';
describe('tableMetadata ducks', () => {
let expectedData: TableMetadata;
......@@ -68,7 +65,6 @@ describe('tableMetadata ducks', () => {
let expectedStatus: number;
let mockSuccess;
let mockFailure;
let updatePayload: UpdateOwnerPayload[];
let testKey: string;
let testIndex: string;
let testSource: string;
......@@ -78,6 +74,7 @@ describe('tableMetadata ducks', () => {
let newDescription: string;
let previewData: PreviewData;
let queryParams: PreviewQueryParams;
beforeAll(() => {
expectedData = globalState.tableMetadata.tableData;
expectedOwners = {
......@@ -97,8 +94,6 @@ describe('tableMetadata ducks', () => {
mockSuccess = jest.fn().mockImplementation(() => {});
mockFailure = jest.fn().mockImplementation(() => {});
updatePayload = [{ method: UpdateMethod.PUT, id: 'testId' }];
testKey = 'tableKey';
testIndex = '3';
testSource = 'search';
......@@ -443,7 +438,6 @@ describe('tableMetadata ducks', () => {
describe('handles request error', () => {
let sagaTest;
beforeAll(() => {
const mockNewTableData: TableMetadata = initialTableDataState;
sagaTest = (action) => {
return testSaga(getTableDescriptionWorker, action)
.next()
......@@ -549,6 +543,7 @@ describe('tableMetadata ducks', () => {
let sagaTest;
beforeAll(() => {
const mockNewTableData: TableMetadata = initialTableDataState;
sagaTest = (action) => {
return testSaga(getColumnDescriptionWorker, action)
.next()
......@@ -579,7 +574,6 @@ describe('tableMetadata ducks', () => {
describe('handles request error', () => {
let sagaTest;
beforeAll(() => {
const mockNewTableData: TableMetadata = initialTableDataState;
sagaTest = (action) => {
return testSaga(getColumnDescriptionWorker, action)
.next()
......
......@@ -4,7 +4,7 @@ import { OwnerDict, UpdateMethod, UpdateOwnerPayload } from 'interfaces';
import globalState from 'fixtures/globalState';
import * as API from '../../api/v0';
import * as API from '../api/v0';
import reducer, {
updateTableOwner,
......@@ -12,20 +12,18 @@ import reducer, {
updateTableOwnerSuccess,
initialOwnersState,
TableOwnerReducerState,
} from '../reducer';
} from './reducer';
import {
getTableData,
getTableDataFailure,
getTableDataSuccess,
} from '../../reducer';
} from '../reducer';
import { updateTableOwnerWorker, updateTableOwnerWatcher } from '../sagas';
import { updateTableOwnerWorker, updateTableOwnerWatcher } from './sagas';
import { GetTableData, UpdateTableOwner } from '../../types';
import { UpdateTableOwner } from '../types';
const generateOwnerUpdateRequestsSpy = jest
.spyOn(API, 'generateOwnerUpdateRequests')
.mockImplementation((payload, key) => []);
jest.spyOn(API, 'generateOwnerUpdateRequests').mockImplementation(() => []);
describe('tableMetadata:owners ducks', () => {
let expectedOwners: OwnerDict;
......
......@@ -5,7 +5,6 @@ import {
PreviewQueryParams,
TableMetadata,
Tag,
User,
} from 'interfaces';
import {
......
......@@ -25,10 +25,12 @@ describe('getAllTags', () => {
config: {},
};
const axiosMock = jest
jest
.spyOn(axios, 'get')
.mockImplementation(() => Promise.resolve(mockResponse));
expect.assertions(1);
await API.getAllTags().then((sortedTags) => {
expect(sortedTags).toEqual(expectedTags);
});
......
......@@ -11,19 +11,19 @@
"build": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' webpack --progress --config webpack.prod.ts",
"dev-build": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' webpack --progress --config webpack.dev.ts",
"test": "cross-env TZ=UTC jest --coverage --collectCoverageFrom=js/**/*.{js,jsx,ts,tsx}",
"test:watch": "cross-env TZ=UTC jest --watch",
"posttest": "npm run format",
"test-nocov": "cross-env TZ=UTC jest",
"watch": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' webpack --progress --config webpack.dev.ts --watch",
"lint": "npm run eslint",
"lint-fix": "npm run eslint-fix",
"lint:fix": "npm run eslint:fix",
"eslint": "eslint --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .",
"eslint:errors": "eslint --ignore-path=.eslintignore --quiet --ext .js,.jsx,.ts,.tsx .",
"eslint-fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .",
"test:watch": "cross-env TZ=UTC jest --watch",
"eslint:fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .",
"tsc": "tsc",
"clean-sass-vars": "find-unused-sass-variables ./js",
"stylelint": "stylelint '**/*.scss'",
"stylelint-fix": "stylelint --fix '**/*.scss'",
"stylelint:fix": "stylelint --fix '**/*.scss'",
"format": "prettier --loglevel warn --write \"**/*.{ts,tsx,css,scss}\"",
"storybook": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' start-storybook -p 6006",
"build-storybook": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' build-storybook"
......@@ -290,7 +290,6 @@
"never"
],
"@typescript-eslint/dot-notation": "warn",
"@typescript-eslint/lines-between-class-members": "warn",
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/member-delimiter-style": [
......@@ -550,7 +549,7 @@
],
"*.scss": [
"prettier --write",
"npm run stylelint-fix"
"npm run stylelint:fix"
]
}
}
......@@ -52,7 +52,7 @@ To run specific tests, run `npm run test-nocov -t <regex>`, where `<regex>` is a
### Developing React Components
To preview React components in isolation, use [Storybook](https://storybook.js.org/). Just add a `<componentName>.story.tsx` file in the same folder as your component. In that file, show your component in different states. Then run `npm run storybook`, which will open your browser to the storybook browse page.
To preview React components in isolation, use [Storybook](https://storybook.js.org/). Just add a `<componentName>.story.tsx` file in the same folder as your component. In that file, show your component in different states. Then run `npm run storybook`, which will open your browser to the storybook browse page.
Using Storybook makes it much easier to quickly iterate on components when getting to certain states requires multiple steps of UI manipulation. The gallery also serves as a convenient place to see what reusable components are available so you can avoid reinventing the wheel.
......@@ -68,8 +68,8 @@ We also use [Prettier][prettier] to help us keep consistent formatting on our Ty
Whenever you want to run these tasks manually, you can execute:
- `npm run lint` to run ESLint and `npm run lint-fix` to auto-fix most of them.
- `npm run stylelint` to run Stylelint and `npm run stylelint-fix` to trigger the auto-fix.
- `npm run lint` to run ESLint and `npm run lint:fix` to auto-fix most of them.
- `npm run stylelint` to run Stylelint and `npm run stylelint:fix` to trigger the auto-fix.
- `npm run format` to run Prettier on both the TypeScript and Sass files
We also check your changed files and format them when you create a new commit, making it easy for you and for the project to keep a consistent code style. We do this leveraging [Husky][husky] and [Lint-staged][lint-staged].
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment