@@ -125,5 +125,43 @@ void main() {
125125 .isFalse ();
126126 assert (! BoolGlobalSetting .placeholderIgnore.default_);
127127 });
128+
129+ group ('set avoids redundant updates' , () {
130+ void checkUpdated (bool ? old, bool ? new_, {required bool expected}) async {
131+ final globalSettings = eg.globalStore (boolGlobalSettings: {
132+ if (old != null ) BoolGlobalSetting .placeholderIgnore: old,
133+ }).settings;
134+
135+ bool updated = false ;
136+ globalSettings.addListener (() => updated = true );
137+
138+ await globalSettings.setBool (BoolGlobalSetting .placeholderIgnore, new_);
139+ check (updated).equals (expected);
140+ }
141+
142+ test ('null to null -> no update' , () async {
143+ checkUpdated (null , null , expected: false );
144+ });
145+
146+ test ('true to true -> no update' , () async {
147+ checkUpdated (true , true , expected: false );
148+ });
149+
150+ test ('false to false -> no update' , () async {
151+ checkUpdated (false , false , expected: false );
152+ });
153+
154+ test ('null to false -> does the update' , () async {
155+ checkUpdated (null , false , expected: true );
156+ });
157+
158+ test ('true to null -> does the update' , () async {
159+ checkUpdated (true , null , expected: true );
160+ });
161+
162+ test ('false to true -> does the update' , () async {
163+ checkUpdated (false , true , expected: true );
164+ });
165+ });
128166 });
129167}
0 commit comments