@@ -11,8 +11,11 @@ const app = loopback()
11
11
// import our mixin.
12
12
require ( '../lib' ) ( app )
13
13
14
- // Connect to db.
15
- const dbConnector = loopback . memory ( )
14
+ // Create datasource.
15
+ const dbConnector = loopback . createDataSource ( {
16
+ connector : loopback . Memory ,
17
+ file : 'db.json' ,
18
+ } )
16
19
17
20
const now = new Date ( )
18
21
@@ -49,6 +52,10 @@ describe('loopback computed property', function() {
49
52
50
53
lt . beforeEach . withApp ( app )
51
54
55
+ before ( function ( ) {
56
+ return Item . destroyAll ( )
57
+ } )
58
+
52
59
before ( function ( done ) {
53
60
new lt . TestDataBuilder ( )
54
61
. define ( 'itemOne' , Item , {
@@ -80,4 +87,23 @@ describe('loopback computed property', function() {
80
87
expect ( this . itemOne . promised ) . to . equal ( 'Item 1: As promised I get back to you!' )
81
88
expect ( this . itemTwo . promised ) . to . equal ( 'Item 2: As promised I get back to you!' )
82
89
} )
90
+
91
+ it ( 'should not store the computed property' , function ( ) {
92
+ return this . itemOne . updateAttributes ( { readonly : false } )
93
+ . then ( item => {
94
+ /* eslint global-require: 0 */
95
+ const db = require ( '../db.json' )
96
+ const itemFromDb = JSON . parse ( db . models . item [ item . id ] )
97
+
98
+ expect ( item ) . to . have . property ( 'readonly' , true )
99
+ expect ( item ) . to . have . property ( 'requestedAt' )
100
+ expect ( item ) . to . have . property ( 'promised' )
101
+
102
+ expect ( itemFromDb ) . to . have . property ( 'id' , item . id )
103
+ expect ( itemFromDb ) . to . have . property ( 'name' , 'Item 1' )
104
+ expect ( itemFromDb ) . to . not . have . property ( 'readonly' )
105
+ expect ( itemFromDb ) . to . not . have . property ( 'requestedAt' )
106
+ expect ( itemFromDb ) . to . not . have . property ( 'promised' )
107
+ } )
108
+ } )
83
109
} )
0 commit comments