@@ -7,10 +7,8 @@ const Pool = require('..')
77describe ( 'lifecycle hooks' , ( ) => {
88 it ( 'are called on connect' , async ( ) => {
99 const pool = new Pool ( {
10- hooks : {
11- connect : ( client ) => {
12- client . HOOK_CONNECT_COUNT = ( client . HOOK_CONNECT_COUNT || 0 ) + 1
13- } ,
10+ onConnect : ( client ) => {
11+ client . HOOK_CONNECT_COUNT = ( client . HOOK_CONNECT_COUNT || 0 ) + 1
1412 } ,
1513 } )
1614 const client = await pool . connect ( )
@@ -25,11 +23,9 @@ describe('lifecycle hooks', () => {
2523
2624 it ( 'are called on connect with an async hook' , async ( ) => {
2725 const pool = new Pool ( {
28- hooks : {
29- connect : async ( client ) => {
30- const res = await client . query ( 'SELECT 1 AS num' )
31- client . HOOK_CONNECT_RESULT = res . rows [ 0 ] . num
32- } ,
26+ onConnect : async ( client ) => {
27+ const res = await client . query ( 'SELECT 1 AS num' )
28+ client . HOOK_CONNECT_RESULT = res . rows [ 0 ] . num
3329 } ,
3430 } )
3531 const client = await pool . connect ( )
@@ -46,10 +42,8 @@ describe('lifecycle hooks', () => {
4642
4743 it ( 'errors out the connect call if the async connect hook rejects' , async ( ) => {
4844 const pool = new Pool ( {
49- hooks : {
50- connect : async ( client ) => {
51- await client . query ( 'SELECT INVALID HERE' )
52- } ,
45+ onConnect : async ( client ) => {
46+ await client . query ( 'SELECT INVALID HERE' )
5347 } ,
5448 } )
5549 try {
@@ -63,10 +57,8 @@ describe('lifecycle hooks', () => {
6357
6458 it ( 'errors out the connect call if the connect hook throws' , async ( ) => {
6559 const pool = new Pool ( {
66- hooks : {
67- connect : ( ) => {
68- throw new Error ( 'connect hook error' )
69- } ,
60+ onConnect : ( ) => {
61+ throw new Error ( 'connect hook error' )
7062 } ,
7163 } )
7264 try {
0 commit comments