Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarDamkjaer committed Dec 4, 2023
1 parent 8f5735b commit fc034bc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/shared/modules/commands/cypher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ jest.mock('shared/modules/dbMeta/dbMetaDuck', () => {
}
})

jest.mock('shared/modules/settings/settingsDuck', () => {
const orig = require.requireActual('shared/modules/dbMeta/dbMetaDuck')
return {
...orig,
shouldUseReadTransactions: () => false
}
})

describe('tx metadata with cypher', () => {
afterEach(() => {
bolt.routedWriteTransaction.mockClear()
Expand Down Expand Up @@ -153,24 +161,26 @@ multiline comment
action.$$responseChannel = $$responseChannel

bus.send(action.type, action)
flushPromises().then(() => {
expect(bolt.routedWriteTransaction).toHaveBeenCalledTimes(1)
expect(bolt.routedWriteTransaction).toHaveBeenCalledWith(
`// comment
flushPromises()
.then(() => {
expect(bolt.routedWriteTransaction).toHaveBeenCalledTimes(1)
expect(bolt.routedWriteTransaction).toHaveBeenCalledWith(
`// comment
/*
multiline comment
*/
// comment
// comment
/*:auto*/ RETURN ":auto"`,
{},
expect.objectContaining({
autoCommit: true
})
)
done()
})
{},
expect.objectContaining({
autoCommit: true
})
)
done()
})
.catch(e => console.error(e))
})
test('it sends the autoCommit flag = false to tx functions on regular cypher', done => {
// Given
Expand Down
8 changes: 8 additions & 0 deletions src/shared/modules/commands/use-db-ww.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ jest.mock('shared/modules/params/paramsDuck', () => {
}
})

jest.mock('shared/modules/settings/settingsDuck', () => {
const orig = require.requireActual('shared/modules/dbMeta/dbMetaDuck')
return {
...orig,
shouldUseReadTransactions: () => false
}
})

jest.mock('shared/modules/dbMeta/dbMetaDuck', () => {
const orig = jest.requireActual('shared/modules/dbMeta/dbMetaDuck')
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ Object {
"showWheelZoomInfo": true,
"theme": "auto",
"useBoltRouting": false,
"useReadTransactions": false,
}
`;

0 comments on commit fc034bc

Please sign in to comment.