Skip to content

Commit

Permalink
Fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dieter Vyncke authored and Dieter Vyncke committed Dec 13, 2023
1 parent 5e3d273 commit d4ee48d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions __tests__/DatabaseLayer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ describe('run statements', () => {
it('with correct params returns first element found', () => {
const fn = jest.fn(async () => ({ rows: [{ id: 1, teste1: 'Daniel', teste2: 3.5, teste3: '{"prop":123}' }] }))
databaseLayer.executeSql = fn
const where = { teste2_eq: 3.5 }
const where = { teste2: { equals: 3.5 } }
return databaseLayer.findBy(where).then(res => {
expect(Qb.query).toBeCalledWith(tableName, { where, limit: 1 })
expect(fn).toBeCalledWith(qbMockReturns, Object.values(where))
expect(fn).toBeCalledWith(qbMockReturns, Object.values(where).map(option => Object.values(option)).flat())
expect(res).toEqual({ id: 1, teste1: 'Daniel', teste2: 3.5, teste3: '{"prop":123}' })
})
})
Expand All @@ -196,7 +196,7 @@ describe('run statements', () => {
const where = { teste2_eq: 3.5 }
return databaseLayer.findBy(where).then(res => {
expect(Qb.query).toBeCalledWith(tableName, { where, limit: 1 })
expect(fn).toBeCalledWith(qbMockReturns, Object.values(where))
expect(fn).toBeCalledWith(qbMockReturns, Object.values(where).map(option => Object.values(option)).flat())
expect(res).toBeUndefined()
})
})
Expand Down
4 changes: 1 addition & 3 deletions src/query_builder/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ const defaultOptions: IQueryOptions<{ id: any }> = {

// Creates the "SELECT" sql statement for find one record
export function find(tableName: string) {
return `SELECT *
FROM ${tableName}
WHERE id = ? LIMIT 1;`
return `SELECT * FROM ${tableName} WHERE id = ? LIMIT 1;`
}

/* Creates the "SELECT" sql statement for query records
Expand Down

0 comments on commit d4ee48d

Please sign in to comment.