Skip to content

Commit

Permalink
dart fix --apply
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 committed Oct 14, 2024
1 parent b08af40 commit 91f955f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions lib/src/storage_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class StorageProvider with SecureStorage {

Future<bool> saveAll(List<Flag> items) async {
for (var item in items) {
final _current = await read(item.key);
if (_current != null) {
final current = await read(item.key);
if (current != null) {
await update(item.key, item);
} else {
await create(item.key, item);
Expand Down
24 changes: 12 additions & 12 deletions test/flagsmith_core_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ void main() {
expect(items, isEmpty);
});
test('Create a flag', () async {
final _created = await storageProvider.create(
final created = await storageProvider.create(
'test_feature', Flag.seed('test_feature', enabled: false));
expect(_created, isTrue);
expect(created, isTrue);
});
test('Save all flags', () async {
final _created = await storageProvider.saveAll([
final created = await storageProvider.saveAll([
Flag.seed('test_feature_a', enabled: false),
Flag.seed('test_feature_b', enabled: true)
]);
expect(_created, isTrue);
final _all = await storageProvider.getAll();
expect(_all, isNotEmpty);
expect(created, isTrue);
final all0 = await storageProvider.getAll();
expect(all0, isNotEmpty);
expect(
_all,
all0,
const TypeMatcher<List<Flag>>().having(
(p0) => p0
.firstWhereOrNull((element) => element.key == 'test_feature_a'),
Expand All @@ -65,15 +65,15 @@ void main() {
});

test('Update all flags', () async {
final _created = await storageProvider.saveAll([
final created = await storageProvider.saveAll([
Flag.seed('test_feature_a', enabled: false),
Flag.seed('test_feature_b', enabled: true)
]);
expect(_created, isTrue);
final _all = await storageProvider.getAll();
expect(_all, isNotEmpty);
expect(created, isTrue);
final all0 = await storageProvider.getAll();
expect(all0, isNotEmpty);
expect(
_all,
all0,
const TypeMatcher<List<Flag>>().having(
(p0) => p0
.firstWhereOrNull((element) => element.key == 'test_feature_a'),
Expand Down
32 changes: 16 additions & 16 deletions test/models/flag_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ void main() {
expect(flag.feature.description, isNotNull);
});
test('When feature successfuly parsed', () async {
final _feature =
final feature =
Feature.fromJson(jsonDecode(featureValue) as Map<String, dynamic>);
expect(_feature, isNotNull);
expect(_feature.id, 2);
expect(feature, isNotNull);
expect(feature.id, 2);
});

test('When flag successfuly parsed', () {
var flag = Flag.fromJson(jsonDecode(testValue) as Map<String, dynamic>);
final _flag = flag.asString();
expect(_flag, isA<String>());
expect(_flag, isNotNull);
expect(_flag, isNotEmpty);
final flag0 = flag.asString();
expect(flag0, isA<String>());
expect(flag0, isNotNull);
expect(flag0, isNotEmpty);
});

test('When flag value successfuly updated', () {
var flag = Flag.fromJson(jsonDecode(testValue) as Map<String, dynamic>);
final _feature = flag.feature.copyWith(initialValue: '12');
final _flag = flag.copyWith(feature: _feature);
final feature = flag.feature.copyWith(initialValue: '12');
final flag0 = flag.copyWith(feature: feature);

expect(flag.feature.initialValue, '10');
expect(_flag.feature.initialValue, '12');
expect(flag.feature.initialValue, isNot(_flag.feature.initialValue));
expect(flag0.feature.initialValue, '12');
expect(flag.feature.initialValue, isNot(flag0.feature.initialValue));
});

test('When flag seed state is enabled', () {
Expand Down Expand Up @@ -100,13 +100,13 @@ void main() {
expect(identity.flags, isNotEmpty);
expect(identity.traits, isNotEmpty);

final _converted = identity.toJson();
expect(_converted, isNotNull);
expect(_converted, isNotEmpty);
final converted = identity.toJson();
expect(converted, isNotNull);
expect(converted, isNotEmpty);

final _copiedIdentity = identity.copyWith(flags: [], traits: []);
final copiedIdentity = identity.copyWith(flags: [], traits: []);
expect(
_copiedIdentity,
copiedIdentity,
const TypeMatcher<FlagsAndTraits>()
.having((e) => e.flags, 'flags are empty', isEmpty)
.having((e) => e.traits, 'traits are empty', isEmpty));
Expand Down
10 changes: 5 additions & 5 deletions test/storage_reactive_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ void main() {
const TypeMatcher<Flag>()
.having((s) => s.enabled, '$myFeature is not enabled', false),
]));
final _toggled = await store.togggleFeature(myFeature);
expect(_toggled, isTrue);
final toggled = await store.togggleFeature(myFeature);
expect(toggled, isTrue);
});

test('Subject value changed when flag was changed.', () async {
await store.clear();
await store.seed(items: seeds);
final _feature = await store.read(myFeature);
expect(_feature, isNotNull);
expect(_feature!.enabled, isTrue);
final feature = await store.read(myFeature);
expect(feature, isNotNull);
expect(feature!.enabled, isTrue);
expect(store.subject(myFeature)?.stream.valueOrNull?.enabled, true);

expect(
Expand Down

0 comments on commit 91f955f

Please sign in to comment.