Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Fix and refactor test/integration/anonym-access.js
Browse files Browse the repository at this point in the history
  • Loading branch information
voidxnull committed Aug 25, 2017
1 parent 0eec2cd commit b06ebcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
6 changes: 5 additions & 1 deletion test-helpers/factories/user.js
Expand Up @@ -17,7 +17,11 @@ const UserFactory = new Factory()
.attr('password', () => faker.internet.password())
.attr('hashed_password', ['password'], password => bcrypt.hashSync(password, 10))
.attr('email_check_hash', '')
.attr('more', { first_login: false });
.attr('more', {
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
first_login: false
});

export default UserFactory;

Expand Down
20 changes: 5 additions & 15 deletions test/integration/anonym-access.js
@@ -1,14 +1,8 @@
/*eslint-env node, mocha */
/*global $dbConfig */
import uuid from 'uuid';
//import sinon from 'sinon';

import expect from '../../test-helpers/expect';
import initBookshelf from '../../src/api/db';


const bookshelf = initBookshelf($dbConfig);
const User = bookshelf.model('User');
import { createUser } from '../../test-helpers/factories/user';

describe('pages that are available for anonym', function () {
// before(() => {
Expand All @@ -21,21 +15,17 @@ describe('pages that are available for anonym', function () {


describe('when user is not logged in', function () {
let user;
beforeEach(async function () {
await new User({
id: uuid.v4(),
username: 'john',
more: '{"lastName": "Smith", "firstName": "John", "first_login": false}',
email: 'john@example.com'
}).save(null, { method: 'insert' });
user = await createUser();
});

afterEach(async function () {
await bookshelf.knex.raw('DELETE FROM users WHERE username=\'john\';');
await user.destroy();
});

it('User profile page works', async function () {
return expect(`/user/john`, 'body to contain', 'John Smith');
await expect(`/user/${user.get('username')}`, 'body to contain', user.fullName);
});
});
});

0 comments on commit b06ebcd

Please sign in to comment.