Browse Source

test(neon): extend Option tests

Signed-off-by: Nikolas Rimikis <rimikis.nikolas@gmail.com>
pull/497/head
Nikolas Rimikis 1 year ago
parent
commit
cfdee6fd12
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 38
      packages/neon/neon/test/option_test.dart

38
packages/neon/neon/test/option_test.dart

@ -174,6 +174,35 @@ void main() {
expect(option.serialize(), null, reason: 'Should serialize to null. A string containing "null" is an error');
});
test('Deserialize', () {
final option = SelectOption<SelectValues?>(
storage: storage,
key: key,
label: labelBuilder,
defaultValue: null,
values: valuesLabel,
);
// ignore: cascade_invocations
option.load('SelectValues.second');
expect(option.value, SelectValues.second);
});
test('Stream', () async {
final option = SelectOption<SelectValues?>(
storage: storage,
key: key,
label: labelBuilder,
defaultValue: null,
values: valuesLabel,
);
expect(await option.stream.first, option.defaultValue);
option.value = SelectValues.second;
expect(await option.stream.first, SelectValues.second);
});
});
group('ToggleOption', () {
@ -274,5 +303,14 @@ void main() {
verify(() => storage.remove(key.value)).called(1);
expect(option.value, option.defaultValue, reason: 'Should reset the value.');
});
test('Deserialize', () {
expect(option.value, true);
// ignore: cascade_invocations
option.load(false);
expect(option.value, false);
});
});
}

Loading…
Cancel
Save