mirror of
https://github.com/wassname/talk.git
synced 2026-08-14 12:50:17 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const {graphql} = require('graphql');
|
||||
const { graphql } = require('graphql');
|
||||
|
||||
const schema = require('../../../../graph/schema');
|
||||
const Context = require('../../../../graph/context');
|
||||
@@ -6,10 +6,9 @@ const UserModel = require('../../../../models/user');
|
||||
const SettingsService = require('../../../../services/settings');
|
||||
const isEqual = require('lodash/isEqual');
|
||||
|
||||
const {expect} = require('chai');
|
||||
const { expect } = require('chai');
|
||||
|
||||
describe('graph.mutations.updateSettings', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await SettingsService.init();
|
||||
});
|
||||
@@ -24,15 +23,14 @@ describe('graph.mutations.updateSettings', () => {
|
||||
}`;
|
||||
|
||||
describe('context with different user roles', () => {
|
||||
|
||||
[
|
||||
{error: 'NOT_AUTHORIZED', role: 'COMMENTER'},
|
||||
{error: 'NOT_AUTHORIZED', role: 'MODERATOR'},
|
||||
{role: 'ADMIN'},
|
||||
].forEach(({role, error}) => {
|
||||
{ error: 'NOT_AUTHORIZED', role: 'COMMENTER' },
|
||||
{ error: 'NOT_AUTHORIZED', role: 'MODERATOR' },
|
||||
{ role: 'ADMIN' },
|
||||
].forEach(({ role, error }) => {
|
||||
it(`role = ${role}`, async () => {
|
||||
const user = new UserModel({role});
|
||||
const ctx = new Context({user});
|
||||
const user = new UserModel({ role });
|
||||
const ctx = new Context({ user });
|
||||
|
||||
const newSettings = {
|
||||
premodLinksEnable: false,
|
||||
@@ -52,7 +50,10 @@ describe('graph.mutations.updateSettings', () => {
|
||||
|
||||
if (error) {
|
||||
expect(res.data.updateSettings.errors).to.not.be.empty;
|
||||
expect(res.data.updateSettings.errors[0]).to.have.property('translation_key', error);
|
||||
expect(res.data.updateSettings.errors[0]).to.have.property(
|
||||
'translation_key',
|
||||
error
|
||||
);
|
||||
} else {
|
||||
if (res.data.updateSettings && res.data.updateSettings.errors) {
|
||||
console.error(res.data.updateSettings.errors);
|
||||
@@ -60,7 +61,7 @@ describe('graph.mutations.updateSettings', () => {
|
||||
expect(res.data.updateSettings).to.be.null;
|
||||
|
||||
const retrievedSettings = await SettingsService.retrieve();
|
||||
Object.keys(newSettings).forEach((key) => {
|
||||
Object.keys(newSettings).forEach(key => {
|
||||
expect(retrievedSettings).to.have.property(key, newSettings[key]);
|
||||
});
|
||||
}
|
||||
@@ -69,8 +70,8 @@ describe('graph.mutations.updateSettings', () => {
|
||||
});
|
||||
|
||||
describe('nested objects', () => {
|
||||
const user = new UserModel({role: 'ADMIN'});
|
||||
const ctx = new Context({user});
|
||||
const user = new UserModel({ role: 'ADMIN' });
|
||||
const ctx = new Context({ user });
|
||||
|
||||
it('should handle nested objects', async () => {
|
||||
const initSettings = {
|
||||
@@ -98,11 +99,16 @@ describe('graph.mutations.updateSettings', () => {
|
||||
expect(res.data.updateSettings).to.be.null;
|
||||
|
||||
let retrievedSettings = await SettingsService.retrieve();
|
||||
Object.keys(initSettings).forEach((key) => {
|
||||
Object.keys(initSettings[key]).forEach((nestedKey) => {
|
||||
Object.keys(initSettings).forEach(key => {
|
||||
Object.keys(initSettings[key]).forEach(nestedKey => {
|
||||
expect(retrievedSettings).to.have.property(key);
|
||||
expect(retrievedSettings[key]).to.have.property(nestedKey);
|
||||
expect(isEqual(retrievedSettings[key][nestedKey], initSettings[key][nestedKey])).to.be.true;
|
||||
expect(
|
||||
isEqual(
|
||||
retrievedSettings[key][nestedKey],
|
||||
initSettings[key][nestedKey]
|
||||
)
|
||||
).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,7 +127,7 @@ describe('graph.mutations.updateSettings', () => {
|
||||
},
|
||||
domains: {
|
||||
whitelist: change.domains.whitelist,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
res = await graphql(schema, QUERY, {}, ctx, {
|
||||
@@ -140,11 +146,16 @@ describe('graph.mutations.updateSettings', () => {
|
||||
expect(res.data.updateSettings).to.be.null;
|
||||
|
||||
retrievedSettings = await SettingsService.retrieve();
|
||||
Object.keys(changedSettings).forEach((key) => {
|
||||
Object.keys(changedSettings[key]).forEach((nestedKey) => {
|
||||
Object.keys(changedSettings).forEach(key => {
|
||||
Object.keys(changedSettings[key]).forEach(nestedKey => {
|
||||
expect(retrievedSettings).to.have.property(key);
|
||||
expect(retrievedSettings[key]).to.have.property(nestedKey);
|
||||
expect(isEqual(retrievedSettings[key][nestedKey], changedSettings[key][nestedKey])).to.be.true;
|
||||
expect(
|
||||
isEqual(
|
||||
retrievedSettings[key][nestedKey],
|
||||
changedSettings[key][nestedKey]
|
||||
)
|
||||
).to.be.true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user