@@ -50,6 +50,46 @@ describe('Integration | Repository | Organization-for-admin', function () {
50
50
expect ( result [ 1 ] . params ) . to . deep . equal ( organizationFeatures [ 1 ] . params ) ;
51
51
} ) ;
52
52
53
+ it ( 'should update existing rows' , async function ( ) {
54
+ // given
55
+ const otherOrganization = databaseBuilder . factory . buildOrganization ( ) ;
56
+ databaseBuilder . factory . buildOrganizationFeature ( {
57
+ featureId : feature . id ,
58
+ organizationId : organization . id ,
59
+ params : `{ "id": 0 }` ,
60
+ } ) ;
61
+ await databaseBuilder . commit ( ) ;
62
+
63
+ const organizationFeatures = [
64
+ new OrganizationFeature ( {
65
+ featureId : feature . id ,
66
+ organizationId : organization . id ,
67
+ params : `["SOMETHING"]` ,
68
+ } ) ,
69
+ new OrganizationFeature ( {
70
+ featureId : feature . id ,
71
+ organizationId : otherOrganization . id ,
72
+ params : `{ "id": 456 }` ,
73
+ } ) ,
74
+ ] ;
75
+
76
+ // when
77
+ await organizationFeatureRepository . saveInBatch ( organizationFeatures ) ;
78
+
79
+ //then
80
+ const result = await knex ( 'organization-features' ) . where ( {
81
+ featureId : feature . id ,
82
+ } ) ;
83
+
84
+ expect ( result ) . to . have . lengthOf ( 2 ) ;
85
+ expect ( result [ 0 ] . featureId ) . to . deep . equal ( organizationFeatures [ 0 ] . featureId ) ;
86
+ expect ( result [ 0 ] . organizationId ) . to . deep . equal ( organizationFeatures [ 0 ] . organizationId ) ;
87
+ expect ( result [ 0 ] . params ) . to . deep . equal ( organizationFeatures [ 0 ] . params ) ;
88
+ expect ( result [ 1 ] . featureId ) . to . deep . equal ( organizationFeatures [ 1 ] . featureId ) ;
89
+ expect ( result [ 1 ] . organizationId ) . to . deep . equal ( organizationFeatures [ 1 ] . organizationId ) ;
90
+ expect ( result [ 1 ] . params ) . to . deep . equal ( organizationFeatures [ 1 ] . params ) ;
91
+ } ) ;
92
+
53
93
it ( 'should passe even if organization feature already exists' , async function ( ) {
54
94
databaseBuilder . factory . buildOrganizationFeature ( { organizationId : organization . id , featureId : feature . id } ) ;
55
95
await databaseBuilder . commit ( ) ;
0 commit comments