mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
fix test lint
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { v4 as generateUUID } from 'uuid';
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration/v3';
|
||||
import { encrypt } from '../../../../../website/server/libs/encryption';
|
||||
import { v4 as generateUUID } from 'uuid';
|
||||
|
||||
describe('GET /email/unsubscribe', () => {
|
||||
let user;
|
||||
let testEmail = 'test@habitica.com';
|
||||
const testEmail = 'test@habitica.com';
|
||||
|
||||
beforeEach(async () => {
|
||||
user = await generateUser();
|
||||
@@ -22,7 +22,7 @@ describe('GET /email/unsubscribe', () => {
|
||||
});
|
||||
|
||||
it('return error when user is not found', async () => {
|
||||
let code = encrypt(JSON.stringify({
|
||||
const code = encrypt(JSON.stringify({
|
||||
_id: generateUUID(),
|
||||
}));
|
||||
|
||||
@@ -34,34 +34,34 @@ describe('GET /email/unsubscribe', () => {
|
||||
});
|
||||
|
||||
it('unsubscribes a user from email notifications', async () => {
|
||||
let code = encrypt(JSON.stringify({
|
||||
const code = encrypt(JSON.stringify({
|
||||
_id: user._id,
|
||||
email: user.email,
|
||||
}));
|
||||
|
||||
await user.get(`/email/unsubscribe?code=${code}`);
|
||||
|
||||
let unsubscribedUser = await user.get('/user');
|
||||
const unsubscribedUser = await user.get('/user');
|
||||
|
||||
expect(unsubscribedUser.preferences.emailNotifications.unsubscribeFromAll).to.be.true;
|
||||
});
|
||||
|
||||
it('unsubscribes an email from notifications', async () => {
|
||||
let code = encrypt(JSON.stringify({
|
||||
const code = encrypt(JSON.stringify({
|
||||
email: testEmail,
|
||||
}));
|
||||
|
||||
let unsubscribedMessage = await user.get(`/email/unsubscribe?code=${code}`);
|
||||
const unsubscribedMessage = await user.get(`/email/unsubscribe?code=${code}`);
|
||||
|
||||
expect(unsubscribedMessage).to.equal('<h1>Unsubscribed successfully!</h1> You won\'t receive any other email from Habitica.');
|
||||
});
|
||||
|
||||
it('returns okay when email is already unsubscribed', async () => {
|
||||
let code = encrypt(JSON.stringify({
|
||||
const code = encrypt(JSON.stringify({
|
||||
email: testEmail,
|
||||
}));
|
||||
|
||||
let unsubscribedMessage = await user.get(`/email/unsubscribe?code=${code}`);
|
||||
const unsubscribedMessage = await user.get(`/email/unsubscribe?code=${code}`);
|
||||
|
||||
expect(unsubscribedMessage).to.equal('<h1>Unsubscribed successfully!</h1> You won\'t receive any other email from Habitica.');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user