Skip to content

Commit

Permalink
No longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrton committed Dec 13, 2023
1 parent dcce32a commit 249bf14
Showing 1 changed file with 0 additions and 121 deletions.
121 changes: 0 additions & 121 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,127 +580,6 @@ describe('execute', () => {
const got = await connection.execute('select document from documents')

expect(got).toEqual(want)
expect(got.rows[0].document).toEqual(want.rows[0].document)
})

test('allows setting the type of rows in the query results', async () => {
const mockResponse = {
session: mockSession,
result: {
fields: [{ name: ':vtg1', type: 'INT32' }, { name: 'null' }],
rows: [{ lengths: ['1', '-1'], values: 'MQ==' }]
},
timing: 1
}

const want = {
headers: [':vtg1', 'null'],
types: { ':vtg1': 'INT32', null: 'NULL' },
fields: [
{ name: ':vtg1', type: 'INT32' },
{ name: 'null', type: 'NULL' }
],
rows: [{ ':vtg1': 1, null: null }],
size: 1,
statement: 'SELECT 1, null from dual;',
rowsAffected: 0,
insertId: '0',
time: 1000
}

interface Got {
':vtg1'?: number
null?: null
}

const isGot = (object: any): object is Got => {
return ':vtg1' in object && 'null' in object
}

mockPool.intercept({ path: EXECUTE_PATH, method: 'POST' }).reply(200, (opts) => {
expect(opts.headers['Authorization']).toMatch(/Basic /)
const bodyObj = JSON.parse(opts.body.toString())
expect(bodyObj.session).toEqual(null)
return mockResponse
})

const connection = connect(config)
const got = await connection.execute<Got>('SELECT 1, null from dual;')

expect(got).toEqual(want)
expect(isGot(got.rows[0])).toBe(true)

mockPool.intercept({ path: EXECUTE_PATH, method: 'POST' }).reply(200, (opts) => {
expect(opts.headers['Authorization']).toMatch(/Basic /)
const bodyObj = JSON.parse(opts.body.toString())
expect(bodyObj.session).toEqual(mockSession)
return mockResponse
})

const got2 = await connection.execute<Got>('SELECT 1, null from dual;')

expect(got2).toEqual(want)
expect(isGot(got2.rows[0])).toBe(true)
})

test('allows setting the type of rows in the query results', async () => {
const mockResponse = {
session: mockSession,
result: {
fields: [{ name: ':vtg1', type: 'INT32' }, { name: 'null' }],
rows: [{ lengths: ['1', '-1'], values: 'MQ==' }]
},
timing: 1
}

const want = {
headers: [':vtg1', 'null'],
types: { ':vtg1': 'INT32', null: 'NULL' },
fields: [
{ name: ':vtg1', type: 'INT32' },
{ name: 'null', type: 'NULL' }
],
rows: [{ ':vtg1': 1, null: null }],
size: 1,
statement: 'SELECT 1, null from dual;',
rowsAffected: 0,
insertId: '0',
time: 1000
}

interface Got {
':vtg1'?: number
null?: null
}

const isGot = (object: any): object is Got => {
return ':vtg1' in object && 'null' in object
}

mockPool.intercept({ path: EXECUTE_PATH, method: 'POST' }).reply(200, (opts) => {
expect(opts.headers['Authorization']).toMatch(/Basic /)
const bodyObj = JSON.parse(opts.body.toString())
expect(bodyObj.session).toEqual(null)
return mockResponse
})

const connection = connect(config)
const got: ExecutedQuery<Got> = await connection.execute('SELECT 1, null from dual;')

expect(got).toEqual(want)
expect(isGot(got.rows[0])).toBe(true)

mockPool.intercept({ path: EXECUTE_PATH, method: 'POST' }).reply(200, (opts) => {
expect(opts.headers['Authorization']).toMatch(/Basic /)
const bodyObj = JSON.parse(opts.body.toString())
expect(bodyObj.session).toEqual(mockSession)
return mockResponse
})

const got2: ExecutedQuery<Got> = await connection.execute('SELECT 1, null from dual;')

expect(got2).toEqual(want)
expect(isGot(got2.rows[0])).toBe(true)
})
})

Expand Down

0 comments on commit 249bf14

Please sign in to comment.