Skip to content

Commit 362b1a1

Browse files
committed
continued testing adding console.logs
1 parent ae73742 commit 362b1a1

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

src/app/RTKslices.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const findName = (index, obj) => {
2424
objChildArray.push(findName(index, objChild));
2525
}
2626
}
27+
console.log(objChildArray);
2728
// eslint-disable-next-line no-restricted-syntax
2829
for (const objChildName of objChildArray) {
2930
if (objChildName) {
@@ -170,17 +171,17 @@ export const mainSlice = createSlice({
170171

171172
changeView: (state, action) => {
172173
const {tabs, currentTab} = state;
173-
// console.log('this is state:', current(state))
174-
// console.log('this is tabs:', current(tabs))
175-
// console.log('this is currentabs:', currentTab)
176-
// console.log('this is tabs[currentab]', current(tabs[currentTab]))
174+
console.log('this is state:', current(state))
175+
console.log('this is tabs:', current(tabs))
176+
console.log('this is currentabs:', currentTab)
177+
console.log('this is tabs[currentab]', current(tabs[currentTab]))
177178
const {viewIndex} = tabs[currentTab] || {};
178179
console.log('hi this is viewIndex:', viewIndex);
179180
console.log('this is action payload', action.payload)
180-
// tabs[currentTab].viewIndex = viewIndex === action.payload ? -1 : action.payload;
181-
if (viewIndex === action.payload) tabs[currentTab].viewIndex = -1;
182-
else tabs[currentTab].viewIndex = action.payload;
183-
tabs[currentTab].currLocation = tabs[currentTab].hierarchy;
181+
tabs[currentTab].viewIndex = viewIndex === action.payload ? -1 : action.payload;
182+
// if (viewIndex === action.payload) tabs[currentTab].viewIndex = -1;
183+
// else tabs[currentTab].viewIndex = action.payload;
184+
// tabs[currentTab].currLocation = tabs[currentTab].hierarchy;
184185

185186
// case types.CHANGE_VIEW: {
186187
// // unselect view if same index was selected
@@ -199,8 +200,15 @@ export const mainSlice = createSlice({
199200
const { port, currentTab, tabs } = state;
200201
const { hierarchy, snapshots } = tabs[currentTab] || {};
201202

203+
console.log('this is PORT', port);
204+
console.log('this is hierarchy', current(hierarchy));
205+
console.log('this is SNapshots', current(snapshots));
206+
202207
const nameFromIndex = findName(action.payload, hierarchy);
203208

209+
console.log('this is action payload', action.payload);
210+
console.log('this is nameFromIndex', nameFromIndex);
211+
204212
port.postMessage({
205213
action: 'jumpToSnap',
206214
payload: snapshots[action.payload],

src/app/__tests__/action.test.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,22 @@ describe('Unit testing for Action.tsx', () => {
110110
// expect(props.handleOnkeyDown).toHaveBeenCalled();
111111
// });
112112

113-
test('Clicking the snapshot should trigger onClick', () => {
114-
render(
115-
<Action {...props} />
116-
)
117-
fireEvent.click(screen.getByRole('presentation'));
118-
expect(props.dispatch).toHaveBeenCalledWith(changeView(props.index));;
119-
});
120-
121-
// test('Clicking Jump button should trigger changeSlider and changeView', () => {
122-
// render(
113+
// test('Clicking the snapshot should trigger onClick', () => {
114+
// render(
123115
// <Action {...props} />
124-
// );
125-
// fireEvent.click(screen.getAllByRole('button')[1]);
126-
// expect(props.dispatch).toHaveBeenCalledWith(changeSlider(props.index));
127-
// expect(props.dispatch).toHaveBeenCalledWith(changeView(props.index));
116+
// )
117+
// fireEvent.click(screen.getByRole('presentation'));
118+
// expect(props.dispatch).toHaveBeenCalledWith(changeView(props.index));;
128119
// });
120+
121+
test('Clicking Jump button should trigger changeSlider and changeView', () => {
122+
render(
123+
<Action {...props} />
124+
);
125+
fireEvent.click(screen.getAllByRole('button')[1]);
126+
expect(props.dispatch).toHaveBeenCalledWith(changeSlider(props.index));
127+
expect(props.dispatch).toHaveBeenCalledWith(changeView(props.index));
128+
});
129129
});
130130
});
131131

src/app/containers/ActionContainer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ function ActionContainer(props): JSX.Element {
6262
obj.stateSnapshot.children[0].state && // with a 'state'
6363
obj.stateSnapshot.children[0].name // and a 'name'
6464
) {
65-
const newObj: Record<string, unknown> = { // we create a new Record object (whose property keys are Keys and whose property values are Type. This utility can be used to map the properties of a type to another type) and populate it's properties with relevant values from our argument 'obj'.
65+
const newObj: Record<string, unknown> = {
66+
// we create a new Record object (whose property keys are Keys and whose property values are Type.
67+
//This utility can be used to map the properties of a type to another type) and populate it's properties with
68+
//relevant values from our argument 'obj'.
6669
index: obj.index,
6770
displayName: `${obj.name}.${obj.branch}`,
6871
state: obj.stateSnapshot.children[0].state,

0 commit comments

Comments
 (0)