Skip to content

Commit 0b89a23

Browse files
committed
refactor: improve code formatting and structure in VideoEditorModal and related components
1 parent d33b6ff commit 0b89a23

6 files changed

Lines changed: 57 additions & 48 deletions

File tree

src/editors/containers/VideoEditor/components/VideoEditorModal.test.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ describe('VideoUploader', () => {
4141
initializeMocks();
4242
});
4343

44-
const renderComponent = () => editorRender(
45-
<VideoEditorModal isLibrary={false} />,
46-
{
47-
routerProps: {
48-
initialEntries: ['/some/path?selectedVideoId=id_1&selectedVideoUrl=https://video.com'],
44+
const renderComponent = () => (
45+
editorRender(
46+
<VideoEditorModal isLibrary={false} />,
47+
{
48+
routerProps: {
49+
initialEntries: ['/some/path?selectedVideoId=id_1&selectedVideoUrl=https://video.com'],
50+
},
51+
initialState,
4952
},
50-
initialState,
51-
},
53+
)
5254
);
5355

5456
it('should render the component and call loadVideoData with correct parameters', async () => {

src/editors/containers/VideoEditor/components/VideoEditorModal.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ const VideoEditorModal: React.FC<Props> = ({
4949
}, [isLoaded, dispatch, selectedVideoId, selectedVideoUrl]);
5050

5151
return (
52-
<VideoSettingsModal {...{
53-
onReturn: onSettingsReturn,
54-
isLibrary,
55-
onClose,
56-
useNewVideoUploadsPage,
57-
}}
52+
<VideoSettingsModal
53+
{...{
54+
onReturn: onSettingsReturn,
55+
isLibrary,
56+
onClose,
57+
useNewVideoUploadsPage,
58+
}}
5859
/>
5960
);
6061
// TODO: add logic to show SelectVideoModal if no selection

src/editors/containers/VideoEditor/components/VideoSettingsModal/index.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {
2-
screen, fireEvent, initializeMocks,
2+
screen,
3+
fireEvent,
4+
initializeMocks,
35
} from '@src/testUtils';
46
import { editorRender } from '@src/editors/editorTestRender';
57
import VideoSettingsModal from '.';

src/editors/containers/VideoEditor/components/VideoSettingsModal/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ const VideoSettingsModal: React.FC<Props> = ({
4949
<ErrorSummary />
5050
<ConnectedVideoPreviewWidget />
5151
<VideoSourceWidget />
52-
{!isLibrary && (
53-
<SocialShareWidget />
54-
)}
52+
{!isLibrary && <SocialShareWidget />}
5553
<ThumbnailWidget />
5654
<TranscriptWidget />
5755
<DurationWidget />

src/editors/containers/VideoGallery/hooks.test.jsx

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,25 @@ jest.mock('react-redux', () => {
99
const actual = jest.requireActual('react-redux');
1010
return {
1111
...actual,
12-
useSelector: jest.fn((selectorFn) => selectorFn({
13-
app: {
14-
learningContextId: 'course-v1:id',
15-
blockId: 'block-v1:id',
16-
},
17-
})),
12+
useSelector: jest.fn((selectorFn) =>
13+
selectorFn({
14+
app: {
15+
learningContextId: 'course-v1:id',
16+
blockId: 'block-v1:id',
17+
},
18+
})
19+
),
1820
};
1921
});
2022

2123
jest.mock('../../hooks', () => ({
2224
navigateTo: jest.fn(),
2325
}));
2426

25-
const createStore = (customState = {}) => configureStore({
26-
reducer: () => customState,
27-
});
27+
const createStore = (customState = {}) =>
28+
configureStore({
29+
reducer: () => customState,
30+
});
2831

2932
describe('hooks module', () => {
3033
describe('useSearchAndSortProps', () => {
@@ -112,21 +115,20 @@ describe('hooks module', () => {
112115
jest.clearAllMocks();
113116
});
114117

115-
const wrapper = ({ children }) => (
116-
<Provider store={createStore()}>{children}</Provider>
117-
);
118+
const wrapper = ({ children }) => <Provider store={createStore()}>{children}</Provider>;
118119

119120
it('navigates to video editor when a video is selected', async () => {
120121
const { result } = renderHook(
121-
() => hooks.useVideoListProps({
122-
searchSortProps: {
123-
searchString: '',
124-
sortBy: 'dateNewest',
125-
filterBy: filterKeys.anyStatus,
126-
hideSelectedVideos: false,
127-
},
128-
videos,
129-
}),
122+
() =>
123+
hooks.useVideoListProps({
124+
searchSortProps: {
125+
searchString: '',
126+
sortBy: 'dateNewest',
127+
filterBy: filterKeys.anyStatus,
128+
hideSelectedVideos: false,
129+
},
130+
videos,
131+
}),
130132
{ wrapper },
131133
);
132134

@@ -145,15 +147,16 @@ describe('hooks module', () => {
145147

146148
it('sets showSelectVideoError to true if no video is selected', () => {
147149
const { result } = renderHook(
148-
() => hooks.useVideoListProps({
149-
searchSortProps: {
150-
searchString: '',
151-
sortBy: 'dateNewest',
152-
filterBy: filterKeys.anyStatus,
153-
hideSelectedVideos: false,
154-
},
155-
videos,
156-
}),
150+
() =>
151+
hooks.useVideoListProps({
152+
searchSortProps: {
153+
searchString: '',
154+
sortBy: 'dateNewest',
155+
filterBy: filterKeys.anyStatus,
156+
hideSelectedVideos: false,
157+
},
158+
videos,
159+
}),
157160
{ wrapper },
158161
);
159162

src/editors/editorTestRender.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ export const editorRender = (
2323
initialState = {},
2424
learningContextId = 'course-v1:Org+COURSE+RUN',
2525
...options
26-
}: Omit<WrapperOptions, 'extraWrapper'> & RouteOptions & { initialState?: PartialEditorState, learningContextId?: string } = {},
26+
}:
27+
& Omit<WrapperOptions, 'extraWrapper'>
28+
& RouteOptions
29+
& { initialState?: PartialEditorState; learningContextId?: string; } = {},
2730
) => {
2831
editorStore = createStore(initialState);
2932

0 commit comments

Comments
 (0)