Skip to content

Commit

Permalink
adjust db tests for seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan-fowlerharper committed Dec 8, 2021
1 parent c61b1a6 commit 972b6ed
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions server/db/__tests__/stonks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,16 @@ describe('getStonksByName', () => {
describe('getUserStonks', () => {
const id = 'auth0|619abd1de3a44d00699e917d'
it('return an array of the users favourite stonks', () => {
expect.assertions(3)
expect.assertions(1)
return db.getUserStonks(id, testDb)
.then(stonks => {
expect(stonks).toHaveLength(4)
expect(stonks[0].stockSymbol).toBe('PFE')
expect(stonks[1].companyName).toBe('Facebook, Inc.')
expect(stonks).toHaveLength(0)
return null
})
})
})

describe('addUserStonks', () => {
describe('addUserStonks, getUserFavourites', () => {
const id = 'auth0|619abd1de3a44d00699e917d'
const stonksId = 6
it('adds a new stonk to the users favourite stonks', () => {
Expand All @@ -102,22 +100,13 @@ describe('addUserStonks', () => {
return db.getUserStonks(id, testDb)
})
.then(stonks => {
expect(stonks).toHaveLength(5)
expect(stonks[0].stockSymbol).toBe('PFE')
expect(stonks[0].companyName).toBe('Pfizer Inc.')
return null
expect(stonks).toHaveLength(1)
expect(stonks[0].id).toBe(stonksId)
return db.getUserFavourites(id, testDb)
})
})
})

describe('getUserFavourites', () => {
const userId = 'auth0|619abd1de3a44d00699e917d'
it('returns an array of the ids, of users favourite stonks', () => {
expect.assertions(2)
return db.getUserFavourites(userId, testDb)
.then(favourites => {
expect(favourites.user).toBe(userId)
expect(favourites.stonks).toHaveLength(4)
.then(favs => {
console.log(favs)
expect(favs.user).toBe(id)
return null
})
})
Expand Down

0 comments on commit 972b6ed

Please sign in to comment.