@@ -26,6 +26,7 @@ import {
26
26
TaskRepository ,
27
27
UserRepository ,
28
28
} from '../fixtures/repositories' ;
29
+ import { ScopedTaskRepository } from '../fixtures/repositories/scoped-task.repository' ;
29
30
30
31
type Entities =
31
32
| 'users'
@@ -42,6 +43,7 @@ describe('Sequelize CRUD Repository (integration)', () => {
42
43
let app : SequelizeSandboxApplication ;
43
44
let userRepo : UserRepository ;
44
45
let taskRepo : TaskRepository ;
46
+ let scopedTaskRepo : ScopedTaskRepository ;
45
47
let developerRepo : DeveloperRepository ;
46
48
let languagesRepo : ProgrammingLanguageRepository ;
47
49
let client : Client ;
@@ -74,6 +76,29 @@ describe('Sequelize CRUD Repository (integration)', () => {
74
76
}
75
77
} ) ;
76
78
79
+ describe ( 'Model settings Support' , ( ) => {
80
+ beforeEach ( async ( ) => {
81
+ await client . get ( '/scoped-tasks/sync-sequelize-model' ) . send ( ) ;
82
+ } ) ;
83
+ it ( 'supports setting a default "scope" in the Model settings' , async ( ) => {
84
+ await Promise . all ( [
85
+ scopedTaskRepo . create ( { title : 'Task 1' } ) ,
86
+ scopedTaskRepo . create ( { title : 'Task 2' } ) ,
87
+ scopedTaskRepo . create ( { title : 'Task 3' } ) ,
88
+ ] ) ;
89
+
90
+ const tasksDefaultLimit = await scopedTaskRepo . find ( ) ;
91
+
92
+ expect ( tasksDefaultLimit . length ) . to . be . eql ( 1 ) ;
93
+
94
+ const tasksCustomLimit = await scopedTaskRepo . find ( {
95
+ limit : 3 ,
96
+ } ) ;
97
+
98
+ expect ( tasksCustomLimit . length ) . to . be . eql ( 3 ) ;
99
+ } ) ;
100
+ } ) ;
101
+
77
102
describe ( 'defaultFn Support' , ( ) => {
78
103
beforeEach ( async ( ) => {
79
104
await client . get ( '/tasks/sync-sequelize-model' ) . send ( ) ;
@@ -919,6 +944,7 @@ describe('Sequelize CRUD Repository (integration)', () => {
919
944
'book.model' ,
920
945
'category.model' ,
921
946
'product.model' ,
947
+ 'scoped-task.model' ,
922
948
'task.model' ,
923
949
] ,
924
950
repositories : [
@@ -934,6 +960,7 @@ describe('Sequelize CRUD Repository (integration)', () => {
934
960
'book.repository' ,
935
961
'category.repository' ,
936
962
'product.repository' ,
963
+ 'scoped-task.repository' ,
937
964
'task.repository' ,
938
965
] ,
939
966
controllers : [
@@ -956,6 +983,7 @@ describe('Sequelize CRUD Repository (integration)', () => {
956
983
'product.controller' ,
957
984
'test.controller.base' ,
958
985
'task.controller' ,
986
+ 'scoped-task.controller' ,
959
987
] ,
960
988
} ;
961
989
@@ -993,6 +1021,7 @@ describe('Sequelize CRUD Repository (integration)', () => {
993
1021
developerRepo = await app . getRepository ( DeveloperRepository ) ;
994
1022
languagesRepo = await app . getRepository ( ProgrammingLanguageRepository ) ;
995
1023
taskRepo = await app . getRepository ( TaskRepository ) ;
1024
+ scopedTaskRepo = await app . getRepository ( ScopedTaskRepository ) ;
996
1025
client = createRestAppClient ( app as RestApplication ) ;
997
1026
}
998
1027
0 commit comments