Created
May 13, 2019 05:53
-
-
Save ea2305/2e58a7dcfb47d9e54894053a49bc3d49 to your computer and use it in GitHub Desktop.
This file contains 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
'use strict' | |
// Importamos test y trait para poder realizar consultas a la api | |
const { test, trait } = use('Test/Suite')('User Login') | |
trait('Test/ApiClient') | |
// Models | |
const User = use('App/Models/User') | |
// user template | |
const test_user = { | |
username: 'test_user', | |
email: '[email protected]', | |
password: 'password' | |
} | |
test('[Login] Request access with bad email', async ({ client }) => { | |
// Create test user | |
const user = await User.create(test_user) | |
// Send request to API with invalid email | |
const response = await client.post('/api/v1/auth/login') | |
.send({ | |
email: '[email protected]', | |
password: 'password' | |
}) | |
.end() | |
// Check response status | |
response.assertStatus(401) | |
// check response content | |
response.assertJSONSubset({ error: 'bad credentials' }) | |
// delete test user | |
await user.delete() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment