Created
September 13, 2018 15:53
-
-
Save vladinator1000/ede68928deae8edbb01974352a7ee64f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jwt from 'jsonwebtoken'; | |
import config from '../config'; | |
import UserModel from '../server/postgres/models/User'; | |
import VenueModel from '../server/postgres/models/Venue'; | |
const { objectContaining, any } = expect; | |
const userModel = new UserModel(); | |
const venueModel = new VenueModel(); | |
const formData = { | |
name: 'Vlady Veselinov', | |
email: '[email protected]', | |
password: 'Heyooo12345.', | |
passwordConfirmation: 'Heyooo12345.', | |
type: 'venue', | |
dateOfBirth: '1994-01-19T23:30:02.630Z', | |
gender: 'male', | |
venueName: 'Test Venue', | |
address: '36 Test Street', | |
description: 'Perfect for people who like unit testing, unlike me.', | |
}; | |
describe('Venue Signup', () => { | |
let user = null; | |
it('create() creates a db row and returns it as object', async () => { | |
user = await userModel.create(formData); | |
expect(user).toHaveProperty('token'); | |
}); | |
it('getUserByEmailVerified() returns undefined if correct email but not verified', async () => { | |
expect(await userModel.getUserByEmailVerified(formData.email)).toBe(undefined); | |
}); | |
it('verifyEmail() returns the user if successful', async () => { | |
const verifiedUser = await userModel.verifyEmail(user.token); | |
expect(verifiedUser).toHaveProperty('id'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment