mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
Restore the userCreated event
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
const CommentModel = require('../../../models/comment');
|
||||
const ActionModel = require('../../../models/action');
|
||||
|
||||
const UsersService = require('../../../services/users');
|
||||
const SettingsService = require('../../../services/settings');
|
||||
const CommentModel = require('../../../models/comment');
|
||||
const CommentsService = require('../../../services/comments');
|
||||
const Context = require('../../../graph/context');
|
||||
const SettingsService = require('../../../services/settings');
|
||||
const UsersService = require('../../../services/users');
|
||||
|
||||
const settings = {
|
||||
id: '1',
|
||||
@@ -119,9 +119,14 @@ describe('services.CommentsService', () => {
|
||||
beforeEach(async () => {
|
||||
await SettingsService.init(settings);
|
||||
|
||||
const ctx = Context.forSystem();
|
||||
await Promise.all([
|
||||
CommentModel.create(comments),
|
||||
UsersService.createLocalUsers(users),
|
||||
Promise.all(
|
||||
users.map(({ email, password, username }) =>
|
||||
UsersService.createLocalUser(ctx, email, password, username)
|
||||
)
|
||||
),
|
||||
ActionModel.create(actions),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const TagsService = require('../../../services/tags');
|
||||
const UsersService = require('../../../services/users');
|
||||
const SettingsService = require('../../../services/settings');
|
||||
|
||||
const CommentModel = require('../../../models/comment');
|
||||
const Context = require('../../../graph/context');
|
||||
|
||||
const chai = require('chai');
|
||||
const expect = chai.expect;
|
||||
@@ -11,7 +11,9 @@ describe('services.TagsService', () => {
|
||||
let comment, user;
|
||||
beforeEach(async () => {
|
||||
await SettingsService.init();
|
||||
const ctx = Context.forSystem();
|
||||
user = await UsersService.createLocalUser(
|
||||
ctx,
|
||||
'stampi@gmail.com',
|
||||
'1Coral!!',
|
||||
'Stampi'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const TokensService = require('../../../services/tokens');
|
||||
const UsersService = require('../../../services/users');
|
||||
const SettingsService = require('../../../services/settings');
|
||||
const Context = require('../../../graph/context');
|
||||
|
||||
const chai = require('chai');
|
||||
chai.use(require('chai-as-promised'));
|
||||
@@ -10,7 +11,9 @@ describe('services.TokensService', () => {
|
||||
let user;
|
||||
beforeEach(async () => {
|
||||
await SettingsService.init();
|
||||
const ctx = Context.forSystem();
|
||||
user = await UsersService.createLocalUser(
|
||||
ctx,
|
||||
'sockmonster@gmail.com',
|
||||
'2Coral!!',
|
||||
'Sockmonster'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const UsersService = require('../../../services/users');
|
||||
const SettingsService = require('../../../services/settings');
|
||||
const mailer = require('../../../services/mailer');
|
||||
const Context = require('../../../graph/context');
|
||||
|
||||
const chai = require('chai');
|
||||
chai.use(require('chai-as-promised'));
|
||||
@@ -18,23 +19,28 @@ describe('services.UsersService', () => {
|
||||
};
|
||||
|
||||
await SettingsService.init(settings);
|
||||
mockUsers = await UsersService.createLocalUsers([
|
||||
{
|
||||
email: 'stampi@gmail.com',
|
||||
username: 'Stampi',
|
||||
password: '1Coral!-',
|
||||
},
|
||||
{
|
||||
email: 'sockmonster@gmail.com',
|
||||
username: 'Sockmonster',
|
||||
password: '2Coral!2',
|
||||
},
|
||||
{
|
||||
email: 'marvel@gmail.com',
|
||||
username: 'Marvel',
|
||||
password: '3Coral!3',
|
||||
},
|
||||
]);
|
||||
const ctx = Context.forSystem();
|
||||
mockUsers = await Promise.all(
|
||||
[
|
||||
{
|
||||
email: 'stampi@gmail.com',
|
||||
username: 'Stampi',
|
||||
password: '1Coral!-',
|
||||
},
|
||||
{
|
||||
email: 'sockmonster@gmail.com',
|
||||
username: 'Sockmonster',
|
||||
password: '2Coral!2',
|
||||
},
|
||||
{
|
||||
email: 'marvel@gmail.com',
|
||||
username: 'Marvel',
|
||||
password: '3Coral!3',
|
||||
},
|
||||
].map(({ email, username, password }) =>
|
||||
UsersService.createLocalUser(ctx, email, password, username)
|
||||
)
|
||||
);
|
||||
|
||||
sinon.spy(mailer, 'send');
|
||||
});
|
||||
@@ -89,19 +95,16 @@ describe('services.UsersService', () => {
|
||||
|
||||
describe('#createLocalUser', () => {
|
||||
it('should not create a user with duplicate username', () => {
|
||||
return UsersService.createLocalUsers([
|
||||
{
|
||||
email: 'otrostampi@gmail.com',
|
||||
username: 'StampiTheSecond',
|
||||
password: '1Coralito!',
|
||||
},
|
||||
])
|
||||
.then(user => {
|
||||
expect(user).to.be.null;
|
||||
})
|
||||
.catch(error => {
|
||||
expect(error).to.not.be.null;
|
||||
});
|
||||
const ctx = Context.forSystem();
|
||||
|
||||
return expect(
|
||||
UsersService.createLocalUser(
|
||||
ctx,
|
||||
'otrostampi@gmail.com',
|
||||
'1Coralito!',
|
||||
'Stampi'
|
||||
)
|
||||
).be.rejected;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user