Skip to content

Commit

Permalink
42 tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-jordan committed Jun 20, 2017
1 parent bc48fcd commit d54ce27
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
18 changes: 18 additions & 0 deletions seeds/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

exports.seed = function(knex, Promise) {
// Deletes ALL existing entries
return knex('users').del()
.then(function () {
// Inserts seed entries
return knex('users').insert([
{
id: 'test_user',
userName: 'test user',
email: '[email protected]',
image: 'test.jpg',
accessToken: '123',
refreshToken: '1234'
}
])
})
}
7 changes: 7 additions & 0 deletions tests/server/auth.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import test from 'ava'

const auth = require('../../server/lib/auth')

test('fake test', t => {
t.pass()
})
48 changes: 48 additions & 0 deletions tests/server/users.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import test from 'ava'

const configureDatabase = require('./helpers/database-config')
configureDatabase(test)

const users = require('../../server/lib/users')

test('create creates a user', t => {
const user = {id: 'asdasd', userName: 'Bob'}
return users.create(user, t.context.connection)
.then((result) => {
return new Promise((resolve, reject) => {
t.is(result[0], 2)
resolve()
})
})
})

test('exists', t => {
return users.exists('test_user', t.context.connection)
.then((result) => {
return new Promise((resolve, reject) => {
t.is(result, true)
resolve()
})
})
})

test('does not exist', t => {
return users.exists('test_user2', t.context.connection)
.then((result) => {
return new Promise((resolve, reject) => {
t.is(result, false)
resolve()
})
})
})

test('getbyid', t => {
return users.getById('test_user', t.context.connection)
.then((result) => {
return new Promise((resolve, reject) => {
t.is(result.userName, 'test user')
t.is(result.accessToken, '123')
resolve()
})
})
})

0 comments on commit d54ce27

Please sign in to comment.