Skip to content

Commit c5ea50c

Browse files
committed
No longer needed
1 parent 44b6577 commit c5ea50c

File tree

1 file changed

+1
-122
lines changed

1 file changed

+1
-122
lines changed

__tests__/index.test.ts

Lines changed: 1 addition & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import SqlString from 'sqlstring'
2-
import { cast, connect, format, hex, ExecutedQuery, DatabaseError } from '../dist/index'
2+
import { cast, connect, format, hex, DatabaseError } from '../dist/index'
33
import { fetch, MockAgent, setGlobalDispatcher } from 'undici'
44
import packageJSON from '../package.json'
55

@@ -580,127 +580,6 @@ describe('execute', () => {
580580
const got = await connection.execute('select document from documents')
581581

582582
expect(got).toEqual(want)
583-
expect(got.rows[0].document).toEqual(want.rows[0].document)
584-
})
585-
586-
test('allows setting the type of rows in the query results', async () => {
587-
const mockResponse = {
588-
session: mockSession,
589-
result: {
590-
fields: [{ name: ':vtg1', type: 'INT32' }, { name: 'null' }],
591-
rows: [{ lengths: ['1', '-1'], values: 'MQ==' }]
592-
},
593-
timing: 1
594-
}
595-
596-
const want = {
597-
headers: [':vtg1', 'null'],
598-
types: { ':vtg1': 'INT32', null: 'NULL' },
599-
fields: [
600-
{ name: ':vtg1', type: 'INT32' },
601-
{ name: 'null', type: 'NULL' }
602-
],
603-
rows: [{ ':vtg1': 1, null: null }],
604-
size: 1,
605-
statement: 'SELECT 1, null from dual;',
606-
rowsAffected: 0,
607-
insertId: '0',
608-
time: 1000
609-
}
610-
611-
interface Got {
612-
':vtg1'?: number
613-
null?: null
614-
}
615-
616-
const isGot = (object: any): object is Got => {
617-
return ':vtg1' in object && 'null' in object
618-
}
619-
620-
mockPool.intercept({ path: EXECUTE_PATH, method: 'POST' }).reply(200, (opts) => {
621-
expect(opts.headers['Authorization']).toMatch(/Basic /)
622-
const bodyObj = JSON.parse(opts.body.toString())
623-
expect(bodyObj.session).toEqual(null)
624-
return mockResponse
625-
})
626-
627-
const connection = connect(config)
628-
const got = await connection.execute<Got>('SELECT 1, null from dual;')
629-
630-
expect(got).toEqual(want)
631-
expect(isGot(got.rows[0])).toBe(true)
632-
633-
mockPool.intercept({ path: EXECUTE_PATH, method: 'POST' }).reply(200, (opts) => {
634-
expect(opts.headers['Authorization']).toMatch(/Basic /)
635-
const bodyObj = JSON.parse(opts.body.toString())
636-
expect(bodyObj.session).toEqual(mockSession)
637-
return mockResponse
638-
})
639-
640-
const got2 = await connection.execute<Got>('SELECT 1, null from dual;')
641-
642-
expect(got2).toEqual(want)
643-
expect(isGot(got2.rows[0])).toBe(true)
644-
})
645-
646-
test('allows setting the type of rows in the query results', async () => {
647-
const mockResponse = {
648-
session: mockSession,
649-
result: {
650-
fields: [{ name: ':vtg1', type: 'INT32' }, { name: 'null' }],
651-
rows: [{ lengths: ['1', '-1'], values: 'MQ==' }]
652-
},
653-
timing: 1
654-
}
655-
656-
const want = {
657-
headers: [':vtg1', 'null'],
658-
types: { ':vtg1': 'INT32', null: 'NULL' },
659-
fields: [
660-
{ name: ':vtg1', type: 'INT32' },
661-
{ name: 'null', type: 'NULL' }
662-
],
663-
rows: [{ ':vtg1': 1, null: null }],
664-
size: 1,
665-
statement: 'SELECT 1, null from dual;',
666-
rowsAffected: 0,
667-
insertId: '0',
668-
time: 1000
669-
}
670-
671-
interface Got {
672-
':vtg1'?: number
673-
null?: null
674-
}
675-
676-
const isGot = (object: any): object is Got => {
677-
return ':vtg1' in object && 'null' in object
678-
}
679-
680-
mockPool.intercept({ path: EXECUTE_PATH, method: 'POST' }).reply(200, (opts) => {
681-
expect(opts.headers['Authorization']).toMatch(/Basic /)
682-
const bodyObj = JSON.parse(opts.body.toString())
683-
expect(bodyObj.session).toEqual(null)
684-
return mockResponse
685-
})
686-
687-
const connection = connect(config)
688-
const got: ExecutedQuery<Got> = await connection.execute('SELECT 1, null from dual;')
689-
690-
expect(got).toEqual(want)
691-
expect(isGot(got.rows[0])).toBe(true)
692-
693-
mockPool.intercept({ path: EXECUTE_PATH, method: 'POST' }).reply(200, (opts) => {
694-
expect(opts.headers['Authorization']).toMatch(/Basic /)
695-
const bodyObj = JSON.parse(opts.body.toString())
696-
expect(bodyObj.session).toEqual(mockSession)
697-
return mockResponse
698-
})
699-
700-
const got2: ExecutedQuery<Got> = await connection.execute('SELECT 1, null from dual;')
701-
702-
expect(got2).toEqual(want)
703-
expect(isGot(got2.rows[0])).toBe(true)
704583
})
705584
})
706585

0 commit comments

Comments
 (0)