-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration test - Eloquent Casted Querying
- Loading branch information
Showing
9 changed files
with
403 additions
and
6 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,17 @@ | ||
## Integration | ||
|
||
There are 3 purposes for this directory | ||
|
||
1. **Integration test**: All files in this directory are written like "real-life-usage", it contains tests to ensure all features are working as expectations. | ||
2. **Definition and Syntax test**: Because the `najs-eloquent` is implemented with Proxy and dynamic function names then we have to ensure that all classes have typed-definition correctly. | ||
3. **Develop and debug**: All bugs which are reproducible in model-level should be written, fixed and tested in this directory | ||
|
||
The directory structure: | ||
|
||
* **models**: Definition of models which are use for integration/definition/syntax testing | ||
* **mongodb**: Setup for mongodb/mongoose driver or environment | ||
* **mysql**: Setup for mysql driver or environment | ||
* **test**: Setup for mysql driver or environment | ||
* * **features**: For integration test | ||
* * **syntax**: For definition and syntax test, if a type-definitions is wrong it's never built successfully | ||
* **ModelFactory.ts**: Factory definition |
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,26 @@ | ||
import { Eloquent, Mongoose } from '../../dist/lib/v1' | ||
|
||
export interface IComment { | ||
user_id?: string | ||
email?: string | ||
name?: string | ||
content: string | ||
like: number | ||
} | ||
|
||
export class Comment extends (Eloquent as Mongoose<IComment>) { | ||
static className: string = 'Comment' | ||
protected static timestamps = true | ||
protected static softDeletes = true | ||
protected static schema = { | ||
user_id: { type: String, required: false }, | ||
email: { type: String, required: false }, | ||
name: { type: String, required: false }, | ||
content: { type: String, required: true }, | ||
like: { type: Number, required: false } | ||
} | ||
|
||
getClassName() { | ||
return Comment.className | ||
} | ||
} |
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
Oops, something went wrong.