💚 ?
This commit is contained in:
@ -18,7 +18,7 @@
|
||||
"sequelize:migrate": "sequelize db:migrate",
|
||||
"test": "npm run test:frontend && npm run test:server",
|
||||
"test:frontend": "jest",
|
||||
"test:server": "jest --config=server/.jestconfig.json --runInBand",
|
||||
"test:server": "jest --config=server/.jestconfig.json --runInBand --forceExit",
|
||||
"precommit": "lint-staged"
|
||||
},
|
||||
"lint-staged": {
|
||||
@ -48,7 +48,7 @@
|
||||
"frontend"
|
||||
],
|
||||
"setupFiles": [
|
||||
"<rootDir>/frontend/utils/setupJest.js",
|
||||
"<rootDir>/setupJest.js",
|
||||
"<rootDir>/__mocks__/window.js"
|
||||
]
|
||||
},
|
||||
|
@ -6,7 +6,7 @@ import { flushdb, seed } from '../test/support';
|
||||
const server = new TestServer(app.callback());
|
||||
|
||||
beforeEach(flushdb);
|
||||
afterAll(() => server.close());
|
||||
afterAll(server.close);
|
||||
|
||||
describe.skip('#auth.signup', async () => {
|
||||
it('should signup a new user', async () => {
|
||||
|
@ -13,12 +13,13 @@ router.post('documents.list', auth(), pagination(), async ctx => {
|
||||
if (direction !== 'ASC') direction = 'DESC';
|
||||
|
||||
const user = ctx.state.user;
|
||||
const documents = await Document.findAll({
|
||||
const userId = user.id;
|
||||
const starredScope = { method: ['withStarred', userId] };
|
||||
const documents = await Document.scope('defaultScope', starredScope).findAll({
|
||||
where: { teamId: user.teamId },
|
||||
order: [[sort, direction]],
|
||||
offset: ctx.state.pagination.offset,
|
||||
limit: ctx.state.pagination.limit,
|
||||
include: [{ model: Star, as: 'starred', where: { userId: user.id } }],
|
||||
});
|
||||
|
||||
const data = await Promise.all(
|
||||
|
@ -6,7 +6,7 @@ import { flushdb, seed } from '../test/support';
|
||||
const server = new TestServer(app.callback());
|
||||
|
||||
beforeEach(flushdb);
|
||||
afterAll(() => server.close());
|
||||
afterAll(server.close);
|
||||
|
||||
describe('#documents.list', async () => {
|
||||
it('should return documents', async () => {
|
||||
|
@ -3,12 +3,12 @@ import TestServer from 'fetch-test-server';
|
||||
import app from '..';
|
||||
import { User } from '../models';
|
||||
|
||||
import { flushdb, seed, sequelize } from '../test/support';
|
||||
import { flushdb, seed } from '../test/support';
|
||||
|
||||
const server = new TestServer(app.callback());
|
||||
|
||||
beforeEach(flushdb);
|
||||
afterAll(() => server.close());
|
||||
afterAll(server.close);
|
||||
|
||||
describe('#user.info', async () => {
|
||||
it('should return known user', async () => {
|
||||
|
@ -130,6 +130,11 @@ Document.associate = models => {
|
||||
},
|
||||
{ override: true }
|
||||
);
|
||||
Document.addScope('withStarred', userId => ({
|
||||
include: [
|
||||
{ model: models.Star, as: 'starred', where: { userId }, required: false },
|
||||
],
|
||||
}));
|
||||
};
|
||||
|
||||
Document.findById = async id => {
|
||||
|
@ -4,8 +4,6 @@ beforeEach(flushdb);
|
||||
|
||||
it('should set JWT secret and password digest', async () => {
|
||||
const { user } = await seed();
|
||||
await user.save();
|
||||
|
||||
expect(user.passwordDigest).toBeTruthy();
|
||||
expect(user.getJwtToken()).toBeTruthy();
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* eslint-disable */
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import toJson from 'enzyme-to-json';
|
||||
import localStorage from '../../__mocks__/localStorage';
|
||||
import localStorage from './__mocks__/localStorage';
|
||||
|
||||
const snap = children => {
|
||||
const wrapper = shallow(children);
|
Reference in New Issue
Block a user