Skip to content

Commit

Permalink
test: add startConnectionSaga test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacper-RF committed Oct 27, 2023
1 parent 130469a commit 426c52b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/desktop/src/renderer/sagas/socket/socket.saga.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { connection, getFactory, Store } from '@quiet/state-manager'
import { FactoryGirl } from 'factory-girl'
import { expectSaga } from 'redux-saga-test-plan'
import { socketActions, WebsocketConnectionPayload } from '../socket/socket.slice'
import { prepareStore } from '../../testUtils/prepareStore'
import { startConnectionSaga } from './socket.saga'

describe('Start Connection Saga', () => {
const dataPort = 1234
let store: Store
let factory: FactoryGirl

beforeEach(async () => {
store = (await prepareStore()).store
factory = await getFactory(store)
})

it('socketIOSecret is null - take setSocketIOSecret', async () => {
const payload: WebsocketConnectionPayload = {
dataPort,
}

await expectSaga(startConnectionSaga, socketActions.startConnection(payload))
.withState(store.getState())
.take(connection.actions.setSocketIOSecret)
.run()
})

it('socketIOSecret already exist', async () => {
const payload: WebsocketConnectionPayload = {
dataPort,
}

store.dispatch(connection.actions.setSocketIOSecret('secret'))

await expectSaga(startConnectionSaga, socketActions.startConnection(payload))
.withState(store.getState())
.not.take(connection.actions.setSocketIOSecret)
.run()
})
})

0 comments on commit 426c52b

Please sign in to comment.