Add some tests
parent
be20b3ba35
commit
d1039411a4
|
|
@ -0,0 +1,99 @@
|
||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
import { Provider } from 'react-redux';
|
||||||
|
import { Route, MemoryRouter } from 'react-router-dom';
|
||||||
|
import { act } from 'react-dom/test-utils';
|
||||||
|
import { createIntl, createIntlCache, RawIntlProvider } from 'react-intl';
|
||||||
|
import App from '../components/App';
|
||||||
|
import ChooseRoom from '../components/ChooseRoom';
|
||||||
|
import RoomContext from '../RoomContext';
|
||||||
|
|
||||||
|
import configureStore from 'redux-mock-store';
|
||||||
|
|
||||||
|
const mockStore = configureStore([]);
|
||||||
|
|
||||||
|
let container;
|
||||||
|
|
||||||
|
let store;
|
||||||
|
|
||||||
|
let intl;
|
||||||
|
|
||||||
|
const roomClient = {};
|
||||||
|
|
||||||
|
beforeEach(() =>
|
||||||
|
{
|
||||||
|
container = document.createElement('div');
|
||||||
|
|
||||||
|
store = mockStore({
|
||||||
|
me : {
|
||||||
|
displayNameInProgress : false,
|
||||||
|
id : 'jesttester',
|
||||||
|
loggedIn : false,
|
||||||
|
loginEnabled : true
|
||||||
|
},
|
||||||
|
room : {
|
||||||
|
},
|
||||||
|
settings : {
|
||||||
|
displayName : 'Jest Tester'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const cache = createIntlCache();
|
||||||
|
|
||||||
|
const locale = 'en';
|
||||||
|
|
||||||
|
intl = createIntl({
|
||||||
|
locale,
|
||||||
|
messages : {}
|
||||||
|
}, cache);
|
||||||
|
|
||||||
|
document.body.appendChild(container);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() =>
|
||||||
|
{
|
||||||
|
document.body.removeChild(container);
|
||||||
|
container = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('<ChooseRoom />', () =>
|
||||||
|
{
|
||||||
|
test('renders chooseroom', () =>
|
||||||
|
{
|
||||||
|
act(() =>
|
||||||
|
{
|
||||||
|
ReactDOM.render(
|
||||||
|
<Provider store={store}>
|
||||||
|
<RawIntlProvider value={intl}>
|
||||||
|
<RoomContext.Provider value={roomClient}>
|
||||||
|
<MemoryRouter initialEntries={[ '/' ]}>
|
||||||
|
<Route path='/' component={ChooseRoom} />
|
||||||
|
</MemoryRouter>
|
||||||
|
</RoomContext.Provider>
|
||||||
|
</RawIntlProvider>
|
||||||
|
</Provider>,
|
||||||
|
container);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('<App />', () =>
|
||||||
|
{
|
||||||
|
test('renders joindialog', () =>
|
||||||
|
{
|
||||||
|
act(() =>
|
||||||
|
{
|
||||||
|
ReactDOM.render(
|
||||||
|
<Provider store={store}>
|
||||||
|
<RawIntlProvider value={intl}>
|
||||||
|
<RoomContext.Provider value={roomClient}>
|
||||||
|
<MemoryRouter initialEntries={[ '/test' ]}>
|
||||||
|
<Route path='/:id' component={App} />
|
||||||
|
</MemoryRouter>
|
||||||
|
</RoomContext.Provider>
|
||||||
|
</RawIntlProvider>
|
||||||
|
</Provider>,
|
||||||
|
container);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,126 @@
|
||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
import { Provider } from 'react-redux';
|
||||||
|
import { act } from 'react-dom/test-utils';
|
||||||
|
import { createIntl, createIntlCache, RawIntlProvider } from 'react-intl';
|
||||||
|
import Room from '../components/Room';
|
||||||
|
import { SnackbarProvider } from 'notistack';
|
||||||
|
import RoomContext from '../RoomContext';
|
||||||
|
|
||||||
|
import configureStore from 'redux-mock-store';
|
||||||
|
|
||||||
|
const mockStore = configureStore([]);
|
||||||
|
|
||||||
|
let container;
|
||||||
|
|
||||||
|
let store;
|
||||||
|
|
||||||
|
let intl;
|
||||||
|
|
||||||
|
const roomClient = {};
|
||||||
|
|
||||||
|
beforeEach(() =>
|
||||||
|
{
|
||||||
|
container = document.createElement('div');
|
||||||
|
|
||||||
|
store = mockStore({
|
||||||
|
chat : [],
|
||||||
|
consumers : {},
|
||||||
|
files : {},
|
||||||
|
lobbyPeers : {},
|
||||||
|
me : {
|
||||||
|
audioDevices : null,
|
||||||
|
audioInProgress : false,
|
||||||
|
canSendMic : false,
|
||||||
|
canSendWebcam : false,
|
||||||
|
canShareFiles : false,
|
||||||
|
canShareScreen : false,
|
||||||
|
displayNameInProgress : false,
|
||||||
|
id : 'jesttester',
|
||||||
|
loggedIn : false,
|
||||||
|
loginEnabled : true,
|
||||||
|
picture : null,
|
||||||
|
raiseHand : false,
|
||||||
|
raiseHandInProgress : false,
|
||||||
|
screenShareInProgress : false,
|
||||||
|
webcamDevices : null,
|
||||||
|
webcamInProgress : false
|
||||||
|
},
|
||||||
|
notifications : [],
|
||||||
|
peerVolumes : {},
|
||||||
|
peers : {},
|
||||||
|
producers : {},
|
||||||
|
room : {
|
||||||
|
accessCode : '',
|
||||||
|
activeSpeakerId : null,
|
||||||
|
fullScreenConsumer : null,
|
||||||
|
inLobby : true,
|
||||||
|
joinByAccessCode : true,
|
||||||
|
joined : false,
|
||||||
|
lockDialogOpen : false,
|
||||||
|
locked : false,
|
||||||
|
mode : 'democratic',
|
||||||
|
name : 'test',
|
||||||
|
selectedPeerId : null,
|
||||||
|
settingsOpen : false,
|
||||||
|
showSettings : false,
|
||||||
|
signInRequired : false,
|
||||||
|
spotlights : [],
|
||||||
|
state : 'connecting',
|
||||||
|
toolbarsVisible : true,
|
||||||
|
torrentSupport : false,
|
||||||
|
windowConsumer : null
|
||||||
|
},
|
||||||
|
settings : {
|
||||||
|
advancedMode : true,
|
||||||
|
displayName : 'Jest Tester',
|
||||||
|
resolution : 'ultra',
|
||||||
|
selectedAudioDevice : 'default',
|
||||||
|
selectedWebcam : 'soifjsiajosjfoi'
|
||||||
|
},
|
||||||
|
toolarea : {
|
||||||
|
currentToolTab : 'chat',
|
||||||
|
toolAreaOpen : false,
|
||||||
|
unreadFiles : 0,
|
||||||
|
unreadMessages : 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const cache = createIntlCache();
|
||||||
|
|
||||||
|
const locale = 'en';
|
||||||
|
|
||||||
|
intl = createIntl({
|
||||||
|
locale,
|
||||||
|
messages : {}
|
||||||
|
}, cache);
|
||||||
|
|
||||||
|
document.body.appendChild(container);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() =>
|
||||||
|
{
|
||||||
|
document.body.removeChild(container);
|
||||||
|
container = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('<Room />', () =>
|
||||||
|
{
|
||||||
|
test('renders correctly', () =>
|
||||||
|
{
|
||||||
|
act(() =>
|
||||||
|
{
|
||||||
|
ReactDOM.render(
|
||||||
|
<Provider store={store}>
|
||||||
|
<RawIntlProvider value={intl}>
|
||||||
|
<SnackbarProvider>
|
||||||
|
<RoomContext.Provider value={roomClient}>
|
||||||
|
<Room />
|
||||||
|
</RoomContext.Provider>
|
||||||
|
</SnackbarProvider>
|
||||||
|
</RawIntlProvider>
|
||||||
|
</Provider>,
|
||||||
|
container);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import RoomClient from '../RoomClient';
|
||||||
|
|
||||||
|
describe('new RoomClient() without paramaters throws Error', () =>
|
||||||
|
{
|
||||||
|
test('Matches the snapshot', () =>
|
||||||
|
{
|
||||||
|
expect(() => new RoomClient()).toThrow(Error);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue