2017-11-16 16:45:01 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { test } = require('ava');
|
|
|
|
const User = require('./user');
|
|
|
|
|
|
|
|
test('should create user', t => {
|
|
|
|
const user = new User({ name: 'ole', email: 'some@email.com' });
|
|
|
|
t.is(user.name, 'ole');
|
|
|
|
t.is(user.email, 'some@email.com');
|
|
|
|
t.is(
|
|
|
|
user.imageUrl,
|
|
|
|
'//www.gravatar.com/avatar/d8ffeba65ee5baf57e4901690edc8e1b?s=42&d=retro'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should require email', t => {
|
|
|
|
const error = t.throws(() => {
|
|
|
|
const user = new User(); // eslint-disable-line
|
|
|
|
}, Error);
|
|
|
|
|
2018-01-17 09:27:47 +01:00
|
|
|
t.is(error.message, 'Email "value" is required');
|
2017-11-16 16:45:01 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Should create user with only email defined', t => {
|
|
|
|
const user = new User({ email: 'some@email.com' });
|
|
|
|
|
|
|
|
t.is(user.email, 'some@email.com');
|
|
|
|
});
|