Skip to content

Commit 38bb8cb

Browse files
committed
changes made to SwitchApp test jsx
1 parent 0ca1006 commit 38bb8cb

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/app/__tests__/SwitchApp.test.jsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,40 @@ describe('Unit testing for SwitchApp.jsx', () => {
1818
currentTab: 100,
1919
tabs: { 100: { snapshots: [1, 2, 3, 4], viewIndex: 1, sliderIndex: 1, title: 'component'} },
2020
};
21-
const tabsArray = [{ value: 100, label: {} }];
2221
const dropdownCurrTabLabel = {
2322
value: 100,
24-
label: {},
23+
label: 'component',
2524
};
2625
// nate and edwin: mockImplementation creates a mock function call
2726
const dispatch = jest.fn();
27+
2828
// nate and edwin: mockImplementation creates a mock state
2929
useStoreContext.mockImplementation(() => [state, dispatch]);
3030

3131
beforeEach(() => {
3232
wrapper = shallow(<SwitchApp />);
33+
dispatch.mockClear();
3334
});
3435

3536
describe('SwitchApp Component', () => {
37+
beforeEach(() => {
38+
wrapper.find('.tab-select-container').simulate('change', {});
39+
});
40+
// console.log('dispatch mock calls', dispatch.mock.calls);
3641
it('SwitchApp component returns <Select /> from react-select library', () => {
3742
expect(wrapper.find('.tab-select-container').type()).toEqual(Select);
3843
expect(wrapper.find('.tab-select-container').props().className).toBe('tab-select-container');
44+
expect(wrapper.find('.tab-select-container').props().value).toEqual(dropdownCurrTabLabel);
45+
});
46+
it('OnChange should run dispatch function', () => {
47+
expect(dispatch.mock.calls.length).toBe(1);
48+
})
49+
it('options prop should be an array', () => {
3950
expect(Array.isArray(wrapper.find('.tab-select-container').props().options)).toBeTruthy();
4051
expect(wrapper.find('.tab-select-container').props().options[0]).toHaveProperty('value');
4152
expect(wrapper.find('.tab-select-container').props().options[0]).toHaveProperty('label');
42-
expect(wrapper.find('.tab-select-container').props()).toEqual(state.currentTab.value);
4353
});
44-
})
54+
});
4555

4656
describe('dropdownCurrTabLabel', () => {
4757
it('should have properties value and label', () => {
@@ -58,8 +68,4 @@ describe('Unit testing for SwitchApp.jsx', () => {
5868
expect(typeof state.tabs).toEqual('object');
5969
});
6070
});
61-
62-
// options should be an array
63-
// value prop should be equal to a number
64-
// check if onChange if the function runs
65-
})
71+
});

0 commit comments

Comments
 (0)