Skip to content

Commit d85c8a4

Browse files
committed
fixed typing/test, ActionContainer.test.tsx
1 parent c9dbe38 commit d85c8a4

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
transform: {
77
'^.+\\.(js|ts|tsx)$': 'ts-jest',
88
},
9-
testPathIgnorePatterns: ['www', './src/backend/__tests__/ignore', './src/app/__tests__enzyme/ignore'],
9+
testPathIgnorePatterns: ['www', './src/backend/__tests__/ignore', './src/app/__tests__enzyme/ignore', './src/backend/__tests__/linkFiber.test.ts' ],
1010
coveragePathIgnorePatterns: ['/src/backend/__tests__/ignore/', '/src/app/__tests__enzyme/ignore'],
1111
transformIgnorePatterns: ['/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)'],
1212
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$',

src/app/FrontendTypes.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ export interface RootState {
148148
}
149149

150150
export interface InitialState {
151-
port: null;
152-
currentTab: null;
153-
currentTitle: string;
154-
tabs: {};
155-
currentTabInApp: null;
151+
port: null | chrome.runtime.Port;
152+
currentTab: null | number;
153+
currentTitle: null | string;
154+
tabs: {} | { [k: string]: { [k: string]: unknown } };
155+
currentTabInApp: null | string;
156156
connectionStatus: boolean;
157157
connectRequested: boolean;
158158
}

src/app/__tests__/ActionContainer.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ import { useDispatch } from 'react-redux';
113113
main: {
114114
port: null,
115115
currentTab: 87, // Update with your desired value
116-
currentTitle: null,
116+
currentTitle: 'test string',
117117
tabs: customTabs, // Replace with the actual (testing) tab data
118-
currentTabInApp: null,
118+
currentTabInApp: 'test string',
119119
connectionStatus: false,
120120
connectRequested: true,
121121
},
@@ -152,7 +152,7 @@ jest.mock('../components/SwitchApp', () => () => {
152152
//here we set it as a jest.fn()
153153
//then we pass it into our actionContainer on render
154154
const setActionViewMock = jest.fn();
155-
155+
const toggleActionContainer = jest.fn();
156156
jest.mock('react-redux', () => ({
157157
...jest.requireActual('react-redux'), // Use the actual react-redux module except for the functions you want to mock
158158
useDispatch: jest.fn(), // set up a mock function for useDispatch
@@ -165,7 +165,7 @@ describe('unit testing for ActionContainer', ()=>{
165165
const dummyDispatch = jest.fn(); //separate mock function created because we need to explicitly define on line 30 what
166166
useDispatchMock.mockReturnValue(dummyDispatch);//exactly useDispatchMock returns (which is a jest.fn())
167167
beforeEach(()=>{
168-
render(<ActionContainer actionView={true} setActionView={setActionViewMock}/>)
168+
render(<ActionContainer actionView={true} setActionView={setActionViewMock} toggleActionContainer ={toggleActionContainer}/>)
169169
});
170170

171171
test('expect top arrow to be rendered', ()=>{
@@ -193,14 +193,14 @@ describe('Integration testing for ActionContainer.tsx', () => {
193193
test('renders the ActionContainer component', () => {
194194
//tests that the clearButton is rendered by testing if we can get "Clear"
195195
//need to set actionView to true to correctly render clearbutton
196-
render(<ActionContainer setActionView={setActionViewMock} actionView={true}/>);
196+
render(<ActionContainer setActionView={setActionViewMock} actionView={true} toggleActionContainer={toggleActionContainer}/>);
197197
const clearButton = screen.getByText('Clear'); // Use an existing element
198198
expect(setActionViewMock).toHaveBeenCalledWith(true);
199199
expect(clearButton).toBeInTheDocument();
200200
});
201201

202202
test('Slider resets on clear button', ()=>{
203-
render(<ActionContainer actionView = {true} setActionView={setActionViewMock}/>)
203+
render(<ActionContainer actionView = {true} setActionView={setActionViewMock} toggleActionContainer={toggleActionContainer}/>)
204204
render( <TravelContainer snapshotsLength={0} />)
205205
fireEvent.click(screen.getAllByRole('button')[0]);
206206
expect(screen.getByRole('slider')).toHaveStyle('left: 0');

src/app/__tests__/ButtonContainer.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ const customInitialState = {
114114
main: {
115115
port: null,
116116
currentTab: 87, // Update with your desired value
117-
currentTitle: null,
117+
currentTitle: 'No Target',
118118
tabs: customTabs, // Replace with the actual (testing) tab data
119-
currentTabInApp: null,
119+
currentTabInApp: 'test string',
120120
connectionStatus: false,
121121
connectRequested: true,
122122
},

0 commit comments

Comments
 (0)