@@ -1411,11 +1411,27 @@ describe("Model", () => {
1411
1411
1412
1412
describe ( "#dup()" , ( ) => {
1413
1413
it ( "returns a new instance of the same object" , ( ) => {
1414
- let author = new Author ( { firstName : "Stephen" } )
1414
+ let author = new Author ( { id : '1' , firstName : "Stephen" } )
1415
+ author . isPersisted = true
1416
+ author . isMarkedForDestruction = true
1417
+ author . isMarkedForDisassociation = true
1418
+
1419
+ let errors = { firstName : { title : "asdf" } } as any
1420
+ author . errors = errors
1415
1421
let duped = author . dup ( )
1416
1422
duped . firstName = "updated"
1417
1423
expect ( author . firstName ) . to . eq ( "Stephen" )
1418
1424
expect ( duped . firstName ) . to . eq ( "updated" )
1425
+ expect ( duped . id ) . to . eq ( "1" )
1426
+ expect ( duped . isPersisted ) . to . eq ( true )
1427
+ expect ( duped . isMarkedForDestruction ) . to . eq ( true )
1428
+ expect ( duped . isMarkedForDisassociation ) . to . eq ( true )
1429
+ expect ( duped . errors ) . to . deep . equal ( { firstName : { title : "asdf" } } )
1430
+ duped . isPersisted = false
1431
+ expect ( author . isPersisted ) . to . eq ( true )
1432
+ let dupErrors = duped . errors as any
1433
+ dupErrors . firstName = "new"
1434
+ expect ( author . errors . firstName ) . to . deep . eq ( { title : "asdf" } )
1419
1435
} )
1420
1436
1421
1437
it ( "does not recast nonenumerables to enumerable" , ( ) => {
0 commit comments