Quellcode durchsuchen

:white_check_mark: Finished editing membership /<profile_id> test

brian_tests
tomit4 vor 2 Jahren
Ursprung
Commit
6e6054afcd

+ 0
- 3
backend/lib/routes/membership/active.js Datei anzeigen

@@ -123,7 +123,6 @@ module.exports = {
123 123
                           'reveal',
124 124
                       )
125 125
                     : undefined
126
-            console.log('revealTags :=>', revealTags)
127 126
 
128 127
             /** If the revealTags exist, the completedProfile's hidden info is
129 128
              * removed and replaced with the completedProfile's user information
@@ -134,12 +133,10 @@ module.exports = {
134 133
                       completedProfiles.map(p => p.user_id),
135 134
                   )
136 135
                 : undefined
137
-            console.log('user :=>', user)
138 136
 
139 137
             // TODO: Refactor this. Is it safe to always use completedProfiles[0]?
140 138
             if (revealTags && user) {
141 139
                 revealTags.forEach(t => {
142
-                    console.log('t :=>', t)
143 140
                     if (!t.tag.tag_description) return
144 141
                     completedProfiles[0][t.tag.tag_description] =
145 142
                         user[t.tag.tag_description]

+ 7
- 13
backend/lib/services/profile/index.js Datei anzeigen

@@ -372,12 +372,8 @@ module.exports = class ProfileService extends Schmervice.Service {
372 372
      * @param {object}
373 373
      */
374 374
     async getTagsFor(profileId, groupingId, category) {
375
-        console.log('profileId :=>', profileId) // [ 1, 2 ]
376
-        console.log('groupingId :=>', groupingId) // [ 1 ]
377
-        console.log('category :=>', category) // 'reveal'
378 375
         const { TagAssociation } = this.server.models()
379 376
         await this._setTagLookup()
380
-        console.log('this.tagLookup :=>', this.tagLookup) // {}
381 377
         let associations = []
382 378
         if (!profileId.length || !groupingId.length) {
383 379
             return associations
@@ -388,20 +384,18 @@ module.exports = class ProfileService extends Schmervice.Service {
388 384
                       .where('grouping_id', groupingId)
389 385
                       .andWhere('profile_id', profileId)
390 386
                 : await TagAssociation.query().andWhere('profile_id', profileId)
391
-            // filter doesn't fire in tests (incorrect format?)
392
-            return associations.map(assoc => ({
393
-                ...assoc,
394
-                tag: this.tagLookup[assoc.tag_id]
395
-                    ? {}
396
-                    : this.tagLookup[assoc.tag_id],
397
-            }))
398
-            /*
387
+            return associations
388
+                .map(assoc => ({
389
+                    ...assoc,
390
+                    tag: !this.tagLookup[assoc.tag_id]
391
+                        ? {}
392
+                        : this.tagLookup[assoc.tag_id],
393
+                }))
399 394
                 .filter(tagWithAssoc => {
400 395
                     return category
401 396
                         ? tagWithAssoc.tag.tag_category == category
402 397
                         : true
403 398
                 })
404
-            */
405 399
         }
406 400
     }
407 401
 

+ 15
- 16
backend/tests/membership.spec.js Datei anzeigen

@@ -16,7 +16,6 @@ const Membership = require('../lib/models/membership')
16 16
 const Tag = require('../lib/models/tag')
17 17
 const TagAssociation = require('../lib/models/tag-association')
18 18
 const User = require('../lib/models/user')
19
-const ZipCode = require('../lib/models/zip-code')
20 19
 const Aspect = require('../lib/models/aspect')
21 20
 const AspectLabel = require('../lib/models/aspect_label')
22 21
 
@@ -93,22 +92,29 @@ const mockReturn = {
93 92
             grouping_id: 1,
94 93
             tag_id: 7,
95 94
             is_deleted: 0,
96
-            tag: {
97
-                tag_category: 'reveal',
98
-            },
99 95
         },
100 96
         {
101 97
             tag_association_id: 2,
102 98
             profile_id: 1,
103 99
             grouping_id: 1,
104
-            tag_id: 7,
100
+            tag_id: 8,
105 101
             is_deleted: 0,
106
-            tag: {
107
-                tag_category: 'reveal',
108
-            },
109 102
         },
110 103
     ],
111
-    tags: [],
104
+    tags: [
105
+        {
106
+            tag_id: 7,
107
+            tag_category: 'reveal',
108
+            tag_description: 'user_name',
109
+            is_active: 1,
110
+        },
111
+        {
112
+            tag_id: 8,
113
+            tag_category: 'reveal',
114
+            tag_description: 'user_email',
115
+            is_active: 1,
116
+        },
117
+    ],
112 118
     labels: [
113 119
         { aspect_id: 1, a: 100, b: 100 },
114 120
         { aspect_id: 2, a: 100, b: 200 },
@@ -164,9 +170,6 @@ test('path /<profile_id> should return ok', async t => {
164 170
         User,
165 171
     })
166 172
 
167
-    // server.registerService(ProfileService)
168
-    // server.registerService(MembershipService)
169
-    // server.registerService(UserService)
170 173
     /**
171 174
      * Register Routes and Services as usual
172 175
      */
@@ -239,15 +242,11 @@ test('path /<profile_id> should return ok', async t => {
239 242
     const { payload } = await server.inject(pathToTest)
240 243
     const res = JSON.parse(payload)
241 244
 
242
-    t.log('res :=>', res)
243 245
     t.deepEqual(res.ok, true)
244 246
     t.deepEqual(res.data.length, 1)
245
-
246
-    /*
247 247
     t.deepEqual(res.data[0].grouping_id, mockReturn.groupings[0].grouping_id)
248 248
     t.deepEqual(
249 249
         res.data[0].profile.user_name,
250 250
         mockReturn.groupings[0].profile.user_name,
251 251
     )
252
-    */
253 252
 })

Laden…
Abbrechen
Speichern