mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
8a2f5fe789
* feat: config database view effects * chore: add tests * chore: config jest * chore: config jest windows * ci: wanrings * chore: config folder effect
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { AuthBackendService, UserBackendService } from '../appflowy_app/stores/effects/user/backend_service';
|
|
import { randomFillSync } from 'crypto';
|
|
import { nanoid } from '@reduxjs/toolkit';
|
|
|
|
beforeAll(() => {
|
|
//@ts-ignore
|
|
window.crypto = {
|
|
// @ts-ignore
|
|
getRandomValues: function (buffer) {
|
|
// @ts-ignore
|
|
return randomFillSync(buffer);
|
|
},
|
|
};
|
|
});
|
|
|
|
describe('User backend service', () => {
|
|
it('sign up', async () => {
|
|
const service = new AuthBackendService();
|
|
const result = await service.autoSignUp();
|
|
expect(result.ok).toBeTruthy;
|
|
});
|
|
|
|
it('sign in', async () => {
|
|
const authService = new AuthBackendService();
|
|
const email = nanoid(4) + '@appflowy.io';
|
|
const password = nanoid(10);
|
|
const signUpResult = await authService.signUp({ name: 'nathan', email: email, password: password });
|
|
expect(signUpResult.ok).toBeTruthy;
|
|
|
|
const signInResult = await authService.signIn({ email: email, password: password });
|
|
expect(signInResult.ok).toBeTruthy;
|
|
});
|
|
|
|
it('get user profile', async () => {
|
|
const service = new AuthBackendService();
|
|
const result = await service.autoSignUp();
|
|
const userProfile = result.unwrap();
|
|
|
|
const userService = new UserBackendService(userProfile.id);
|
|
expect((await userService.getUserProfile()).unwrap()).toBe(userProfile);
|
|
});
|
|
});
|