test: refactored all test cases with new user type change
This commit is contained in:
@@ -5,6 +5,7 @@ import { UserSettingsService } from './user-settings.service';
|
||||
import { JSON_INVALID, USER_SETTINGS_NULL_SETTINGS } from 'src/errors';
|
||||
import { UserSettings } from './user-settings.model';
|
||||
import { User } from 'src/user/user.model';
|
||||
import { AuthUser } from 'src/types/AuthUser';
|
||||
|
||||
const mockPrisma = mockDeep<PrismaService>();
|
||||
const mockPubSub = mockDeep<PubSubService>();
|
||||
@@ -16,12 +17,20 @@ const userSettingsService = new UserSettingsService(
|
||||
mockPubSub as any,
|
||||
);
|
||||
|
||||
const user: User = {
|
||||
const currentTime = new Date();
|
||||
|
||||
const user: AuthUser = {
|
||||
uid: 'aabb22ccdd',
|
||||
displayName: 'user-display-name',
|
||||
email: 'user-email',
|
||||
photoURL: 'user-photo-url',
|
||||
isAdmin: false,
|
||||
refreshToken: 'hbfvdkhjbvkdvdfjvbnkhjb',
|
||||
currentGQLSession: {},
|
||||
currentRESTSession: {},
|
||||
createdOn: currentTime,
|
||||
};
|
||||
|
||||
const settings: UserSettings = {
|
||||
id: '1',
|
||||
userUid: user.uid,
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
USER_SETTINGS_NULL_SETTINGS,
|
||||
USER_SETTINGS_NOT_FOUND,
|
||||
} from 'src/errors';
|
||||
import { AuthUser } from 'src/types/AuthUser';
|
||||
|
||||
@Injectable()
|
||||
export class UserSettingsService {
|
||||
@@ -46,7 +47,7 @@ export class UserSettingsService {
|
||||
* @param properties stringified user settings properties
|
||||
* @returns an Either of `UserSettings` or error
|
||||
*/
|
||||
async createUserSettings(user: User, properties: string) {
|
||||
async createUserSettings(user: AuthUser, properties: string) {
|
||||
if (!properties) return E.left(USER_SETTINGS_NULL_SETTINGS);
|
||||
|
||||
const jsonProperties = stringToJson(properties);
|
||||
@@ -80,7 +81,7 @@ export class UserSettingsService {
|
||||
* @param properties stringified user settings
|
||||
* @returns Promise of an Either of `UserSettings` or error
|
||||
*/
|
||||
async updateUserSettings(user: User, properties: string) {
|
||||
async updateUserSettings(user: AuthUser, properties: string) {
|
||||
if (!properties) return E.left(USER_SETTINGS_NULL_SETTINGS);
|
||||
|
||||
const jsonProperties = stringToJson(properties);
|
||||
|
||||
Reference in New Issue
Block a user