replaced eslint:recommended with prettier

This commit is contained in:
Wyatt Johnson
2018-01-11 20:00:34 -07:00
parent d56c19016a
commit 0abc2ca243
649 changed files with 16235 additions and 13008 deletions
+90 -26
View File
@@ -1,11 +1,11 @@
const {graphql} = require('graphql');
const { graphql } = require('graphql');
const schema = require('../../../../graph/schema');
const Context = require('../../../../graph/context');
const UsersService = require('../../../../services/users');
const SettingsService = require('../../../../services/settings');
const {expect} = require('chai');
const { expect } = require('chai');
const ignoreUserMutation = `
mutation ignoreUser ($id: ID!) {
@@ -34,11 +34,25 @@ describe('graph.mutations.ignoreUser', () => {
});
it('users can ignoreUser', async () => {
let currentUser = await UsersService.createLocalUser('usernameA@example.com', 'password', 'usernameA');
const userToIgnore = await UsersService.createLocalUser('usernameB@example.com', 'password', 'usernameB');
let context = new Context({user: currentUser});
let currentUser = await UsersService.createLocalUser(
'usernameA@example.com',
'password',
'usernameA'
);
const userToIgnore = await UsersService.createLocalUser(
'usernameB@example.com',
'password',
'usernameB'
);
let context = new Context({ user: currentUser });
const ignoreUserResponse = await graphql(schema, ignoreUserMutation, {}, context, {id: userToIgnore.id});
const ignoreUserResponse = await graphql(
schema,
ignoreUserMutation,
{},
context,
{ id: userToIgnore.id }
);
if (ignoreUserResponse.errors && ignoreUserResponse.errors.length) {
console.error(ignoreUserResponse.errors);
}
@@ -47,10 +61,16 @@ describe('graph.mutations.ignoreUser', () => {
// Refresh the user from the database and create the new context for the
// request.
currentUser = await UsersService.findById(currentUser.id);
context = new Context({user: currentUser});
context = new Context({ user: currentUser });
// now check my ignored users
const myIgnoredUsersResponse = await graphql(schema, getMyIgnoredUsersQuery, {}, context, {});
const myIgnoredUsersResponse = await graphql(
schema,
getMyIgnoredUsersQuery,
{},
context,
{}
);
if (myIgnoredUsersResponse.errors && myIgnoredUsersResponse.errors.length) {
console.error(myIgnoredUsersResponse.errors);
}
@@ -63,13 +83,29 @@ describe('graph.mutations.ignoreUser', () => {
});
it('users cannot ignore themselves', async () => {
const user = await UsersService.createLocalUser('usernameA@example.com', 'password', 'usernameA');
const context = new Context({user});
const ignoreUserResponse = await graphql(schema, ignoreUserMutation, {}, context, {id: user.id});
const user = await UsersService.createLocalUser(
'usernameA@example.com',
'password',
'usernameA'
);
const context = new Context({ user });
const ignoreUserResponse = await graphql(
schema,
ignoreUserMutation,
{},
context,
{ id: user.id }
);
expect(ignoreUserResponse.errors).to.not.be.empty;
// now check my ignored users
const myIgnoredUsersResponse = await graphql(schema, getMyIgnoredUsersQuery, {}, context, {});
const myIgnoredUsersResponse = await graphql(
schema,
getMyIgnoredUsersQuery,
{},
context,
{}
);
if (myIgnoredUsersResponse.errors && myIgnoredUsersResponse.errors.length) {
console.error(myIgnoredUsersResponse.errors);
}
@@ -77,7 +113,6 @@ describe('graph.mutations.ignoreUser', () => {
const myIgnoredUsers = myIgnoredUsersResponse.data.me.ignoredUsers;
expect(myIgnoredUsers.length).to.equal(0);
});
});
describe('graph.mutations.stopIgnoringUser', () => {
@@ -86,20 +121,35 @@ describe('graph.mutations.stopIgnoringUser', () => {
});
it('users can stop ignoring another user they ignore', async () => {
// We're going to ignore 2 users,
// then stopIgnoring 1 of them
// then assert myIgnoredUsers only lists the one remaining
let currentUser = await UsersService.createLocalUser('usernameA@example.com', 'password', 'usernameA');
let currentUser = await UsersService.createLocalUser(
'usernameA@example.com',
'password',
'usernameA'
);
const usersToIgnore = await Promise.all([
UsersService.createLocalUser('usernameB@example.com', 'password', 'usernameB'),
UsersService.createLocalUser('usernameC@example.com', 'password', 'usernameC'),
UsersService.createLocalUser(
'usernameB@example.com',
'password',
'usernameB'
),
UsersService.createLocalUser(
'usernameC@example.com',
'password',
'usernameC'
),
]);
let context = new Context({user: currentUser});
let context = new Context({ user: currentUser });
// ignore two users
const ignoreUserResponses = await Promise.all(usersToIgnore.map((u) => graphql(schema, ignoreUserMutation, {}, context, {id: u.id})));
ignoreUserResponses.forEach((response) => {
const ignoreUserResponses = await Promise.all(
usersToIgnore.map(u =>
graphql(schema, ignoreUserMutation, {}, context, { id: u.id })
)
);
ignoreUserResponses.forEach(response => {
if (response.errors && response.errors.length) {
console.error(response.errors);
}
@@ -109,7 +159,7 @@ describe('graph.mutations.stopIgnoringUser', () => {
// Refresh the user from the database and create the new context for the
// request.
currentUser = await UsersService.findById(currentUser.id);
context = new Context({user: currentUser});
context = new Context({ user: currentUser });
const stopIgnoringUserMutation = `
mutation stopIgnoringUser ($id: ID!) {
@@ -122,8 +172,17 @@ describe('graph.mutations.stopIgnoringUser', () => {
`;
// stop ignoring one user
const stopIgnoringUserResponse = await graphql(schema, stopIgnoringUserMutation, {}, context, {id: usersToIgnore[0].id});
if (stopIgnoringUserResponse.errors && stopIgnoringUserResponse.errors.length) {
const stopIgnoringUserResponse = await graphql(
schema,
stopIgnoringUserMutation,
{},
context,
{ id: usersToIgnore[0].id }
);
if (
stopIgnoringUserResponse.errors &&
stopIgnoringUserResponse.errors.length
) {
console.error(stopIgnoringUserResponse.errors);
}
expect(stopIgnoringUserResponse.errors).to.be.empty;
@@ -131,10 +190,16 @@ describe('graph.mutations.stopIgnoringUser', () => {
// Refresh the user from the database and create the new context for the
// request.
currentUser = await UsersService.findById(currentUser.id);
context = new Context({user: currentUser});
context = new Context({ user: currentUser });
// now check my ignored users
const myIgnoredUsersResponse = await graphql(schema, getMyIgnoredUsersQuery, {}, context, {});
const myIgnoredUsersResponse = await graphql(
schema,
getMyIgnoredUsersQuery,
{},
context,
{}
);
if (myIgnoredUsersResponse.errors && myIgnoredUsersResponse.errors.length) {
console.error(myIgnoredUsersResponse.errors);
}
@@ -144,5 +209,4 @@ describe('graph.mutations.stopIgnoringUser', () => {
expect(myIgnoredUsers[0].id).to.equal(usersToIgnore[1].id);
expect(myIgnoredUsers[0].username).to.equal(usersToIgnore[1].username);
});
});