1
- const { entity, field } = require ( "@herbsjs/gotu" )
1
+ const { entity, field, id } = require ( "@herbsjs/gotu" )
2
2
const Repository = require ( "../../src/repository" )
3
3
const assert = require ( "assert" )
4
4
@@ -7,7 +7,7 @@ describe("Update an Entity", () => {
7
7
const ParentEntity = entity ( 'A Parent Entity' , { } )
8
8
9
9
return entity ( 'A entity' , {
10
- id : field ( Number ) ,
10
+ id : id ( String ) ,
11
11
stringTest : field ( String ) ,
12
12
booleanTest : field ( Boolean ) ,
13
13
entityTest : field ( ParentEntity ) ,
@@ -29,9 +29,9 @@ describe("Update an Entity", () => {
29
29
collection : ( f ) => {
30
30
spy . collectionName = f
31
31
return {
32
- updateOne : ( p ) => {
32
+ findOneAndUpdate : ( p ) => {
33
33
spy . payload = p
34
- { return { modifiedCount : 1 , upsertedCount : 1 } }
34
+ { return { ok : '1' , value : { _id : "70edc25fc39277307ca9a700" , string_test : "test" , boolean_test : true } } }
35
35
}
36
36
}
37
37
}
@@ -49,15 +49,15 @@ describe("Update an Entity", () => {
49
49
mongodb : mongodb ( spy )
50
50
} )
51
51
52
- anEntity . id = 1
52
+ anEntity . id = "70edc25fc39277307ca9a700"
53
53
anEntity . stringTest = "test"
54
54
anEntity . booleanTest = true
55
55
56
56
//when
57
57
const ret = await itemRepo . update ( anEntity )
58
58
59
59
//then
60
- assert . deepStrictEqual ( ret , true )
60
+ assert . deepStrictEqual ( ret . stringTest , "test" )
61
61
} )
62
62
63
63
} )
0 commit comments