-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from zhumeisongsong/feature/domain-prompt
✨ WellbeingPromptEntity and DailyPromptRecordEntity
- Loading branch information
Showing
21 changed files
with
233 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# daily-prompt-record-entity | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test daily-prompt-record-entity` to execute the unit tests via [Jest](https://jestjs.io). |
3 changes: 3 additions & 0 deletions
3
libs/prompt/domain/daily-prompt-record-entity/eslint.config.js
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,3 @@ | ||
const baseConfig = require('../../../../eslint.config.js'); | ||
|
||
module.exports = [...baseConfig]; |
11 changes: 11 additions & 0 deletions
11
libs/prompt/domain/daily-prompt-record-entity/jest.config.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,11 @@ | ||
export default { | ||
displayName: 'daily-prompt-record-entity', | ||
preset: '../../../../jest.preset.js', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: | ||
'../../../../coverage/libs/prompt/domain/daily-prompt-record-entity', | ||
}; |
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,9 @@ | ||
{ | ||
"name": "daily-prompt-record-entity", | ||
"$schema": "../../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/prompt/domain/daily-prompt-record-entity/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"// targets": "to see all targets run: nx show project daily-prompt-record-entity --web", | ||
"targets": {} | ||
} |
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 @@ | ||
export * from './lib/daily-prompt-record-entity'; |
35 changes: 35 additions & 0 deletions
35
libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.spec.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 {type DailyPromptRecordEntity } from './daily-prompt-record-entity'; | ||
|
||
describe('DailyPromptRecordEntity', () => { | ||
it('should have all required properties', () => { | ||
const record: DailyPromptRecordEntity = { | ||
id: '1', | ||
promptId: 'prompt1', | ||
userId: 'user1', | ||
createdAt: new Date(), | ||
completedAt: new Date(), | ||
}; | ||
|
||
expect(record).toHaveProperty('id'); | ||
expect(record).toHaveProperty('promptId'); | ||
expect(record).toHaveProperty('userId'); | ||
expect(record).toHaveProperty('createdAt'); | ||
expect(record).toHaveProperty('completedAt'); | ||
}); | ||
|
||
it('should have correct types for properties', () => { | ||
const record: DailyPromptRecordEntity = { | ||
id: '1', | ||
promptId: 'prompt1', | ||
userId: 'user1', | ||
createdAt: new Date(), | ||
completedAt: new Date(), | ||
}; | ||
|
||
expect(typeof record.id).toBe('string'); | ||
expect(typeof record.promptId).toBe('string'); | ||
expect(typeof record.userId).toBe('string'); | ||
expect(record.createdAt).toBeInstanceOf(Date); | ||
expect(record.completedAt).toBeInstanceOf(Date); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
libs/prompt/domain/daily-prompt-record-entity/src/lib/daily-prompt-record-entity.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,7 @@ | ||
export interface DailyPromptRecordEntity { | ||
id: string; | ||
promptId: string; | ||
userId: string; | ||
createdAt: Date; | ||
completedAt?: Date; | ||
} |
22 changes: 22 additions & 0 deletions
22
libs/prompt/domain/daily-prompt-record-entity/tsconfig.json
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,22 @@ | ||
{ | ||
"extends": "../../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noPropertyAccessFromIndexSignature": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
libs/prompt/domain/daily-prompt-record-entity/tsconfig.lib.json
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,11 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "../../../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"], | ||
"include": ["src/**/*.ts"] | ||
} |
14 changes: 14 additions & 0 deletions
14
libs/prompt/domain/daily-prompt-record-entity/tsconfig.spec.json
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,14 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": [ | ||
"jest.config.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.d.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,7 @@ | ||
# wellbeing-prompt-entity | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test wellbeing-prompt-entity` to execute the unit tests via [Jest](https://jestjs.io). |
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,3 @@ | ||
const baseConfig = require('../../../../eslint.config.js'); | ||
|
||
module.exports = [...baseConfig]; |
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,11 @@ | ||
export default { | ||
displayName: 'wellbeing-prompt-entity', | ||
preset: '../../../../jest.preset.js', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: | ||
'../../../../coverage/libs/prompt/domain/wellbeing-prompt-entity', | ||
}; |
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,9 @@ | ||
{ | ||
"name": "wellbeing-prompt-entity", | ||
"$schema": "../../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/prompt/domain/wellbeing-prompt-entity/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"// targets": "to see all targets run: nx show project wellbeing-prompt-entity --web", | ||
"targets": {} | ||
} |
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 @@ | ||
export * from './lib/wellbeing-prompt-entity'; |
18 changes: 18 additions & 0 deletions
18
libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.spec.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,18 @@ | ||
import { WellbeingPromptEntity } from './wellbeing-prompt-entity'; | ||
|
||
describe('WellbeingPromptEntity', () => { | ||
it('should create a valid WellbeingPromptEntity object', () => { | ||
const wellbeingPrompt: WellbeingPromptEntity = { | ||
id: '1', | ||
content: 'Take a 5-minute walk outside.', | ||
category: 'physical', | ||
createdAt: new Date(), | ||
}; | ||
|
||
expect(wellbeingPrompt).toBeDefined(); | ||
expect(wellbeingPrompt.id).toBe('1'); | ||
expect(wellbeingPrompt.content).toBe('Take a 5-minute walk outside.'); | ||
expect(wellbeingPrompt.category).toBe('physical'); | ||
expect(wellbeingPrompt.createdAt).toBeInstanceOf(Date); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
libs/prompt/domain/wellbeing-prompt-entity/src/lib/wellbeing-prompt-entity.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,17 @@ | ||
type WellbeingCategory = | ||
| 'physical' | ||
| 'mental' | ||
| 'social' | ||
| 'emotional' | ||
| 'mindfulness' | ||
| 'productivity' | ||
| 'self-care' | ||
| 'gratitude' | ||
| 'creativity'; | ||
|
||
export interface WellbeingPromptEntity { | ||
id: string; | ||
content: string; | ||
category: WellbeingCategory; | ||
createdAt: Date; | ||
} |
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,16 @@ | ||
{ | ||
"extends": "../../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
libs/prompt/domain/wellbeing-prompt-entity/tsconfig.lib.json
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,11 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "../../../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"], | ||
"include": ["src/**/*.ts"] | ||
} |
14 changes: 14 additions & 0 deletions
14
libs/prompt/domain/wellbeing-prompt-entity/tsconfig.spec.json
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,14 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": [ | ||
"jest.config.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.d.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