@@ -28,8 +28,9 @@ import {
28
28
DONE as DISCOVERY_DONE ,
29
29
updateDiscoveryConnection
30
30
} 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'
33
34
34
35
jest . mock ( 'services/bolt/bolt' , ( ) => {
35
36
return {
@@ -39,14 +40,6 @@ jest.mock('services/bolt/bolt', () => {
39
40
}
40
41
} )
41
42
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
-
50
43
describe ( 'connections reducer' , ( ) => {
51
44
test ( 'handles connections.SET_ACTIVE' , ( ) => {
52
45
const initialState : any = {
@@ -505,10 +498,12 @@ describe('handleForcePasswordChangeEpic', () => {
505
498
)
506
499
507
500
const mockSessionClose = jest . fn ( )
501
+ const mockSessionExecuteWrite = jest . fn ( )
508
502
509
503
const mockDriver = {
510
504
session : jest . fn ( ) . mockReturnValue ( {
511
- close : mockSessionClose
505
+ close : mockSessionClose ,
506
+ executeWrite : mockSessionExecuteWrite
512
507
} ) ,
513
508
close : jest . fn ( ) . mockReturnValue ( true )
514
509
}
@@ -576,9 +571,7 @@ describe('handleForcePasswordChangeEpic', () => {
576
571
577
572
test ( 'handleForcePasswordChangeEpic resolves when successfully executing cypher query' , ( ) => {
578
573
// Given
579
- ; ( buildTxFunctionByMode as jest . Mock ) . mockReturnValue ( ( ) =>
580
- Promise . resolve ( )
581
- )
574
+ mockSessionExecuteWrite . mockResolvedValue ( true )
582
575
583
576
const p = new Promise < void > ( ( resolve , reject ) => {
584
577
bus . take ( $$responseChannel , currentAction => {
@@ -632,11 +625,11 @@ describe('handleForcePasswordChangeEpic', () => {
632
625
633
626
test ( 'handleForcePasswordChangeEpic resolves with an error if cypher query fails' , ( ) => {
634
627
// 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.' )
638
631
)
639
- . mockReturnValue ( ( ) => Promise . resolve ( ) )
632
+ . mockResolvedValue ( true )
640
633
641
634
const p = new Promise < void > ( ( resolve , reject ) => {
642
635
bus . take ( $$responseChannel , currentAction => {
@@ -682,11 +675,9 @@ describe('handleForcePasswordChangeEpic', () => {
682
675
683
676
test ( 'handleForcePasswordChangeEpic resolves when successfully falling back to dbms function call' , ( ) => {
684
677
// 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 )
690
681
691
682
const p = new Promise < void > ( ( resolve , reject ) => {
692
683
bus . take ( $$responseChannel , currentAction => {
@@ -740,13 +731,9 @@ describe('handleForcePasswordChangeEpic', () => {
740
731
741
732
test ( 'handleForcePasswordChangeEpic resolves with an error if dbms function call fails' , ( ) => {
742
733
// 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.' ) )
750
737
751
738
const p = new Promise < void > ( ( resolve , reject ) => {
752
739
bus . take ( $$responseChannel , currentAction => {
0 commit comments