@@ -28,8 +28,9 @@ import {
2828 DONE as DISCOVERY_DONE ,
2929 updateDiscoveryConnection
3030} from 'shared/modules/discovery/discoveryDuck'
31- import forceResetPasswordQueryHelper from './forceResetPasswordQueryHelper'
32- import { buildTxFunctionByMode } from 'services/bolt/boltHelpers'
31+ import forceResetPasswordQueryHelper , {
32+ MultiDatabaseNotSupportedError
33+ } from './forceResetPasswordQueryHelper'
3334
3435jest . mock ( 'services/bolt/bolt' , ( ) => {
3536 return {
@@ -39,14 +40,6 @@ jest.mock('services/bolt/bolt', () => {
3940 }
4041} )
4142
42- jest . mock ( 'services/bolt/boltHelpers' , ( ) => {
43- const orig = jest . requireActual ( 'services/bolt/boltHelpers' )
44- return {
45- ...orig ,
46- buildTxFunctionByMode : jest . fn ( )
47- }
48- } )
49-
5043describe ( 'connections reducer' , ( ) => {
5144 test ( 'handles connections.SET_ACTIVE' , ( ) => {
5245 const initialState : any = {
@@ -505,10 +498,12 @@ describe('handleForcePasswordChangeEpic', () => {
505498 )
506499
507500 const mockSessionClose = jest . fn ( )
501+ const mockSessionExecuteWrite = jest . fn ( )
508502
509503 const mockDriver = {
510504 session : jest . fn ( ) . mockReturnValue ( {
511- close : mockSessionClose
505+ close : mockSessionClose ,
506+ executeWrite : mockSessionExecuteWrite
512507 } ) ,
513508 close : jest . fn ( ) . mockReturnValue ( true )
514509 }
@@ -576,9 +571,7 @@ describe('handleForcePasswordChangeEpic', () => {
576571
577572 test ( 'handleForcePasswordChangeEpic resolves when successfully executing cypher query' , ( ) => {
578573 // Given
579- ; ( buildTxFunctionByMode as jest . Mock ) . mockReturnValue ( ( ) =>
580- Promise . resolve ( )
581- )
574+ mockSessionExecuteWrite . mockResolvedValue ( true )
582575
583576 const p = new Promise < void > ( ( resolve , reject ) => {
584577 bus . take ( $$responseChannel , currentAction => {
@@ -632,11 +625,11 @@ describe('handleForcePasswordChangeEpic', () => {
632625
633626 test ( 'handleForcePasswordChangeEpic resolves with an error if cypher query fails' , ( ) => {
634627 // Given
635- ; ( buildTxFunctionByMode as jest . Mock )
636- . mockReturnValueOnce ( ( ) =>
637- Promise . reject ( new Error ( 'A password must be at least 8 characters.' ) )
628+ mockSessionExecuteWrite
629+ . mockRejectedValueOnce (
630+ new Error ( 'A password must be at least 8 characters.' )
638631 )
639- . mockReturnValue ( ( ) => Promise . resolve ( ) )
632+ . mockResolvedValue ( true )
640633
641634 const p = new Promise < void > ( ( resolve , reject ) => {
642635 bus . take ( $$responseChannel , currentAction => {
@@ -682,11 +675,9 @@ describe('handleForcePasswordChangeEpic', () => {
682675
683676 test ( 'handleForcePasswordChangeEpic resolves when successfully falling back to dbms function call' , ( ) => {
684677 // Given
685- ; ( buildTxFunctionByMode as jest . Mock )
686- . mockReturnValueOnce ( ( ) =>
687- Promise . reject ( new Error ( "Invalid input 'A': expected <init>" ) )
688- )
689- . mockReturnValue ( ( ) => Promise . resolve ( ) )
678+ mockSessionExecuteWrite
679+ . mockRejectedValueOnce ( new MultiDatabaseNotSupportedError ( ) )
680+ . mockResolvedValue ( true )
690681
691682 const p = new Promise < void > ( ( resolve , reject ) => {
692683 bus . take ( $$responseChannel , currentAction => {
@@ -740,13 +731,9 @@ describe('handleForcePasswordChangeEpic', () => {
740731
741732 test ( 'handleForcePasswordChangeEpic resolves with an error if dbms function call fails' , ( ) => {
742733 // Given
743- ; ( buildTxFunctionByMode as jest . Mock )
744- . mockReturnValueOnce ( ( ) =>
745- Promise . reject ( new Error ( "Invalid input 'A': expected <init>" ) )
746- )
747- . mockReturnValue ( ( ) =>
748- Promise . reject ( new Error ( 'A password must be at least 8 characters.' ) )
749- )
734+ mockSessionExecuteWrite
735+ . mockRejectedValueOnce ( new MultiDatabaseNotSupportedError ( ) )
736+ . mockRejectedValue ( new Error ( 'A password must be at least 8 characters.' ) )
750737
751738 const p = new Promise < void > ( ( resolve , reject ) => {
752739 bus . take ( $$responseChannel , currentAction => {
0 commit comments