-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestUtils.js
More file actions
49 lines (43 loc) · 1.86 KB
/
testUtils.js
File metadata and controls
49 lines (43 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import {expect} from '@jest/globals';
import React from 'react';
import {render} from '@testing-library/react';
import {Provider} from 'react-redux';
import {createStore} from 'redux';
import reducer from 'redux/reducer.js';
import {createMuiTheme, ThemeProvider, StylesProvider} from '@material-ui/core/styles';
import {CloudinaryContext} from 'cloudinary-react';
export const tmdbConfMatchingObj = {
images: {
base_url: expect.stringMatching(/^http:\/\/\S+\/$/),
secure_base_url: expect.stringMatching(/^https:\/\/\S+\/$/),
backdrop_sizes: expect.toSatisfyAll(e => typeof e === 'string'),
logo_sizes: expect.toSatisfyAll(e => typeof e === 'string'),
poster_sizes: expect.toSatisfyAll(e => typeof e === 'string'),
profile_sizes: expect.toSatisfyAll(e => typeof e === 'string'),
still_sizes: expect.toSatisfyAll(e => typeof e === 'string')
},
change_keys: expect.toSatisfyAll(e => typeof e === 'string')
};
export const movieMatchingObj = {
tmdbId: expect.toBeNumber(),
imdbId: expect.stringMatching(/^tt\d+$/),
title: expect.toBeString(),
genres: expect.toSatisfyAll(e => typeof e === 'string'),
imdbRating: expect.stringMatching(/^\d{1,2}\.\d$/),
posterPath: expect.stringMatching(/^\/\S+\.(jpe?g|png)$/),
backdropPath: expect.stringMatching(/^\/\S+\.(jpe?g|png)$/)
};
export const customRender = (ui, {initialState, ...options}) => render(ui, {
...options,
wrapper: ({children}) => (
<Provider store={createStore(reducer, initialState || {})}>
<StylesProvider injectFirst>
<ThemeProvider theme={createMuiTheme()}>
<CloudinaryContext cloudName="befeepilf" secure>
{children}
</CloudinaryContext>
</ThemeProvider>
</StylesProvider>
</Provider>
)
});