-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the version of sign in ,sign up and sign out. Co-authored-by: Joseph Dvorak <[email protected]>
- Loading branch information
1 parent
8526a20
commit a9e7a2f
Showing
8 changed files
with
179 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//Provide structuredClone() as a global variable so that fake-indexeddb can | ||
//access it. | ||
import 'core-js/actual/structured-clone.js'; | ||
//Import reflect-metadata so that Inversify decorators work as expected. | ||
import 'reflect-metadata'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,34 +2,56 @@ import 'reflect-metadata'; | |
import { UserType } from '@/model/enums/user-type'; | ||
import { LocalUserService } from '@/services/classes/concrete/local-user-service'; | ||
import { Subscription } from 'rxjs'; | ||
|
||
describe('LocalUserService', () => { | ||
//TODO : Remove this file from replace these tests as each method in LocalUserService is implemented. | ||
test('It throws an error when the unimplemented signUpWithEmail() method is called.', () => { | ||
const userService = new LocalUserService(); | ||
expect(() => | ||
userService.signUpWithEmail( | ||
'[email protected]', | ||
'user', | ||
1, | ||
UserType.Challenger, | ||
), | ||
).toThrow(); | ||
let userService: LocalUserService; | ||
|
||
beforeEach(() => { | ||
userService = new LocalUserService(); | ||
}); | ||
|
||
test('It throws an error when the unimplemented signInWithEmail() method is called.', () => { | ||
const userService = new LocalUserService(); | ||
expect(() => userService.signInWithEmail('[email protected]')).toThrow(); | ||
test('It successfully signs up a new user with valid data', async () => { | ||
await expect(userService.signUpWithEmail( | ||
'[email protected]', | ||
'user', | ||
1, | ||
UserType.Challenger, | ||
)).resolves.toBeUndefined(); | ||
|
||
// Additional assertions can be made to check if the user is correctly set, etc. | ||
}); | ||
|
||
test('It throws an error when the unimplemented signOut() method is called.', () => { | ||
const userService = new LocalUserService(); | ||
expect(() => userService.signOut()).toThrow(); | ||
test('It successfully signs in an existing user with valid email', async () => { | ||
// Assuming a user with email '[email protected]' exists in the database | ||
await expect(userService.signInWithEmail('[email protected]')).resolves.toBeUndefined(); | ||
|
||
// Additional assertions can be made to check if the user is correctly set, etc. | ||
}); | ||
|
||
test('It throws an error when signing in with an invalid email', async () => { | ||
await expect(userService.signInWithEmail('[email protected]')).rejects.toThrow('User not found'); | ||
}); | ||
|
||
test('It successfully signs out a signed-in user', async () => { | ||
// Assuming a user is signed in before signing out | ||
await userService.signInWithEmail('[email protected]'); | ||
|
||
userService.signOut(); | ||
|
||
expect(userService.user).toBeNull(); | ||
}); | ||
|
||
test('It throws an error when signing out without a signed-in user', () => { | ||
expect(() => userService.signOut()).not.toThrow(); // No error expected when signing out without a signed-in user | ||
}); | ||
|
||
test('When its subscribe() method is called, an RxJS Subscription is returned.', () => { | ||
const subscription = userService.subscribe(() => {}); | ||
expect(subscription).toBeInstanceOf(Subscription); | ||
}); | ||
//original version I store it. | ||
test('When its subscribe() method is called, an RxJS Subscription is returned.', () => { | ||
const userService = new LocalUserService(); | ||
const subscription = userService.subscribe(() => {}); | ||
expect(subscription).toBeInstanceOf(Subscription); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ | |
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} | ||
} |