From cfdee6fd1292c6688d99ef0857ed8d0389b37280 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Tue, 29 Aug 2023 17:13:35 +0200 Subject: [PATCH] test(neon): extend Option tests Signed-off-by: Nikolas Rimikis --- packages/neon/neon/test/option_test.dart | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/neon/neon/test/option_test.dart b/packages/neon/neon/test/option_test.dart index d3e28036..585ddcd7 100644 --- a/packages/neon/neon/test/option_test.dart +++ b/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( + 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( + 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); + }); }); }