@@ -153,3 +153,54 @@ test('prepared statement with explicit portal', function () {
153153 } )
154154 } )
155155} )
156+
157+ var describeClient = helper . client ( )
158+ var describeCon = describeClient . connection
159+ describeCon . parse = function ( arg ) {
160+ process . nextTick ( function ( ) {
161+ describeCon . emit ( 'parseComplete' )
162+ } )
163+ }
164+ var describeDescribeArg = null
165+ describeCon . describe = function ( arg ) {
166+ describeDescribeArg = arg
167+ }
168+
169+ var describeFlushCalled = false
170+ describeCon . flush = function ( ) {
171+ describeFlushCalled = true
172+ process . nextTick ( function ( ) {
173+ describeCon . emit ( 'paramDescription' , { params : [ ] } )
174+ describeCon . emit ( 'rowDescription' , { fields : [ ] } )
175+ } )
176+ }
177+
178+ var describeSyncCalled = false
179+ describeCon . sync = function ( ) {
180+ process . nextTick ( function ( ) {
181+ describeSyncCalled = true
182+ describeCon . emit ( 'readyForQuery' )
183+ } )
184+ }
185+
186+ test ( 'describe prepared statement' , function ( ) {
187+ assert . ok ( describeClient . connection . emit ( 'readyForQuery' ) )
188+
189+ var query = describeClient . query ( new Query ( {
190+ text : 'select * from X where name = $1' ,
191+ describe : true
192+ } ) )
193+
194+ assert . emits ( query , 'end' , function ( ) {
195+ test ( 'describe argument' , function ( ) {
196+ assert . equal ( describeDescribeArg . type , 'S' )
197+ assert . equal ( describeDescribeArg . name , undefined )
198+ } )
199+ test ( 'flush called' , function ( ) {
200+ assert . ok ( describeFlushCalled )
201+ } )
202+ test ( 'sync called' , function ( ) {
203+ assert . ok ( describeSyncCalled )
204+ } )
205+ } )
206+ } )
0 commit comments