-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* scaffold next app * added PR template, preliminary model, createNamedContext and useContextSafely hooks * updated image locations * implemented and tested useContextSafely * migrated footer, page container and modal * migrated header * added home page * implemented servicesContainer and ServicesContext, scaffolded LocalUserService * simplified cb returned by useLayoutEffect hook in UserContextProvider * reverted cb to arrow function in UserContextProvider * updated github actions/checkout and setup-node to v4 * added local-user-service.ts to coveragePathIgnorePatterns array in jest.config.mjs * fixed several merge conflicts, formatted code
- Loading branch information
Showing
20 changed files
with
348 additions
and
37 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
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { | ||
ServicesContext, | ||
ServicesContextProvider, | ||
} from '@/contexts/services-context'; | ||
import { getProvidedContextValue } from '@/testing-utils/get-provided-context-value'; | ||
import { AbstractUserService } from '@/services/classes/abstract/abstract-user-service'; | ||
|
||
describe('ServicesContext', () => { | ||
it('provides an instance of AbstractUserService to its consumers.', () => { | ||
const servicesContextValue = getProvidedContextValue( | ||
ServicesContext, | ||
ServicesContextProvider, | ||
); | ||
expect(servicesContextValue).not.toBeNull(); | ||
expect(servicesContextValue?.userService).toBeInstanceOf( | ||
AbstractUserService, | ||
); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
src/__tests__/services/classes/concrete/local-user-service.test.ts
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,35 @@ | ||
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(); | ||
}); | ||
|
||
test('It throws an error when the unimplemented signInWithEmail() method is called.', () => { | ||
const userService = new LocalUserService(); | ||
expect(() => userService.signInWithEmail('[email protected]')).toThrow(); | ||
}); | ||
|
||
test('It throws an error when the unimplemented signOut() method is called.', () => { | ||
const userService = new LocalUserService(); | ||
expect(() => userService.signOut()).toThrow(); | ||
}); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { servicesContainer } from '@/services/services-container'; | ||
import { TYPES } from '@/services/types'; | ||
import { AbstractUserService } from '@/services/classes/abstract/abstract-user-service'; | ||
|
||
describe('servicesContainer', () => { | ||
it('Provides a subclass of the AbstractUserService service class.', () => { | ||
const userService = servicesContainer.get<AbstractUserService>( | ||
TYPES.UserService, | ||
); | ||
expect(userService).toBeInstanceOf(AbstractUserService); | ||
}); | ||
}); |
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,25 @@ | ||
'use client'; | ||
import { servicesContainer } from '@/services/services-container'; | ||
import { createNamedContext } from '@/hooks/functions/create-named-context'; | ||
import { TYPES } from '@/services/types'; | ||
import type { AbstractUserService } from '@/services/classes/abstract/abstract-user-service'; | ||
import type { PropsWithChildren } from 'react'; | ||
|
||
interface ServicesContextType { | ||
userService: AbstractUserService; | ||
} | ||
|
||
export const ServicesContext = | ||
createNamedContext<ServicesContextType>('ServicesContext'); | ||
|
||
export function ServicesContextProvider({ children }: PropsWithChildren) { | ||
const userService = servicesContainer.get<AbstractUserService>( | ||
TYPES.UserService, | ||
); | ||
|
||
return ( | ||
<ServicesContext.Provider value={{ userService }}> | ||
{children} | ||
</ServicesContext.Provider> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Avatar } from './avatar.type'; | ||
|
||
/** | ||
* Represents data about a challenger that is stored in a player's user document. | ||
*/ | ||
export interface Challenger { | ||
uid: string; | ||
name: string; | ||
avatar: Avatar; | ||
} |
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
Oops, something went wrong.