mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
feat(challenge7): reorganisation
This commit is contained in:
3
libs/ngrx-notification/model/src/index.ts
Normal file
3
libs/ngrx-notification/model/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './lib/push.model';
|
||||
export * from './lib/student.model';
|
||||
export * from './lib/teacher.model';
|
||||
5
libs/ngrx-notification/model/src/lib/push.model.ts
Normal file
5
libs/ngrx-notification/model/src/lib/push.model.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export type PushType = 'teacher' | 'student';
|
||||
|
||||
export interface Push {
|
||||
type: PushType;
|
||||
}
|
||||
28
libs/ngrx-notification/model/src/lib/student.model.ts
Normal file
28
libs/ngrx-notification/model/src/lib/student.model.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import {
|
||||
incrementalNumber,
|
||||
randFirstName,
|
||||
randLastName,
|
||||
randWord,
|
||||
} from '@ngneat/falso';
|
||||
import { Push } from './push.model';
|
||||
|
||||
export interface Student extends Push {
|
||||
id: number;
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
school: string;
|
||||
}
|
||||
|
||||
const factoryStudent = incrementalNumber();
|
||||
|
||||
export const randStudent = (): Student => ({
|
||||
id: factoryStudent(),
|
||||
firstname: randFirstName(),
|
||||
lastname: randLastName(),
|
||||
school: randWord(),
|
||||
type: 'student',
|
||||
});
|
||||
|
||||
export const isStudent = (notif: Push): notif is Student => {
|
||||
return notif.type === 'student';
|
||||
};
|
||||
37
libs/ngrx-notification/model/src/lib/teacher.model.ts
Normal file
37
libs/ngrx-notification/model/src/lib/teacher.model.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
incrementalNumber,
|
||||
rand,
|
||||
randFirstName,
|
||||
randLastName,
|
||||
} from '@ngneat/falso';
|
||||
import { Push } from './push.model';
|
||||
|
||||
export const subject = [
|
||||
'Sciences',
|
||||
'History',
|
||||
'English',
|
||||
'Maths',
|
||||
'Sport',
|
||||
] as const;
|
||||
export type Subject = typeof subject[number];
|
||||
|
||||
export interface Teacher extends Push {
|
||||
id: number;
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
subject: Subject;
|
||||
}
|
||||
|
||||
const factoryTeacher = incrementalNumber();
|
||||
|
||||
export const randTeacher = (): Teacher => ({
|
||||
id: factoryTeacher(),
|
||||
firstname: randFirstName(),
|
||||
lastname: randLastName(),
|
||||
subject: rand(subject),
|
||||
type: 'teacher',
|
||||
});
|
||||
|
||||
export const isTeacher = (notif: Push): notif is Teacher => {
|
||||
return notif.type === 'teacher';
|
||||
};
|
||||
1
libs/ngrx-notification/model/src/test-setup.ts
Normal file
1
libs/ngrx-notification/model/src/test-setup.ts
Normal file
@@ -0,0 +1 @@
|
||||
import 'jest-preset-angular/setup-jest';
|
||||
Reference in New Issue
Block a user