@@ -563,6 +563,48 @@ void main() {
563
563
});
564
564
});
565
565
566
+ group ('PerAccountStore.customProfileFields' , () {
567
+ test ('update clobbers old list' , () async {
568
+ final store = eg.store (initialSnapshot: eg.initialSnapshot (
569
+ customProfileFields: [
570
+ eg.customProfileField (0 , CustomProfileFieldType .shortText),
571
+ eg.customProfileField (1 , CustomProfileFieldType .shortText),
572
+ ]));
573
+ check (store.customProfileFields.map ((f) => f.id)).deepEquals ([0 , 1 ]);
574
+
575
+ await store.handleEvent (CustomProfileFieldsEvent (id: 0 , fields: [
576
+ eg.customProfileField (0 , CustomProfileFieldType .shortText),
577
+ eg.customProfileField (2 , CustomProfileFieldType .shortText),
578
+ ]));
579
+ check (store.customProfileFields.map ((f) => f.id)).deepEquals ([0 , 2 ]);
580
+ });
581
+
582
+ test ('sorts by displayInProfile' , () async {
583
+ // Sorts both the data from the initial snapshot…
584
+ final store = eg.store (initialSnapshot: eg.initialSnapshot (
585
+ customProfileFields: [
586
+ eg.customProfileField (0 , CustomProfileFieldType .shortText,
587
+ displayInProfileSummary: false ),
588
+ eg.customProfileField (1 , CustomProfileFieldType .shortText,
589
+ displayInProfileSummary: true ),
590
+ eg.customProfileField (2 , CustomProfileFieldType .shortText,
591
+ displayInProfileSummary: false ),
592
+ ]));
593
+ check (store.customProfileFields.map ((f) => f.id)).deepEquals ([1 , 0 , 2 ]);
594
+
595
+ // … and from an event.
596
+ await store.handleEvent (CustomProfileFieldsEvent (id: 0 , fields: [
597
+ eg.customProfileField (0 , CustomProfileFieldType .shortText,
598
+ displayInProfileSummary: false ),
599
+ eg.customProfileField (1 , CustomProfileFieldType .shortText,
600
+ displayInProfileSummary: false ),
601
+ eg.customProfileField (2 , CustomProfileFieldType .shortText,
602
+ displayInProfileSummary: true ),
603
+ ]));
604
+ check (store.customProfileFields.map ((f) => f.id)).deepEquals ([2 , 0 , 1 ]);
605
+ });
606
+ });
607
+
566
608
group ('PerAccountStore.handleEvent' , () {
567
609
// Mostly this method just dispatches to ChannelStore and MessageStore etc.,
568
610
// and so its tests generally live in the test files for those
0 commit comments