From d8ca8e0235e8c81ecc79aca0403585a8fc1e9611 Mon Sep 17 00:00:00 2001 From: "Leo Y. Li" Date: Tue, 23 Apr 2019 22:33:50 -0400 Subject: [PATCH] ADD addon-contexts: tests on serializers --- .../contexts/src/shared/serializers.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 addons/contexts/src/shared/serializers.test.ts diff --git a/addons/contexts/src/shared/serializers.test.ts b/addons/contexts/src/shared/serializers.test.ts new file mode 100644 index 000000000000..4e97b1986f10 --- /dev/null +++ b/addons/contexts/src/shared/serializers.test.ts @@ -0,0 +1,19 @@ +import { deserialize, serialize } from './serializers'; + +describe('Test on serializers', () => { + const someContextsQueryParam = 'CSS Themes=Forests,Languages=Fr'; + const someSelectionState = { + 'CSS Themes': 'Forests', + Languages: 'Fr', + }; + + it('Should serialize selection state into its string representation', () => { + expect(serialize(null)).toEqual(null); + expect(serialize(someSelectionState)).toEqual(someContextsQueryParam); + }); + + it('Should deserialize a string representation into the represented selection state', () => { + expect(deserialize('')).toEqual(undefined); + expect(deserialize(someContextsQueryParam)).toEqual(someSelectionState); + }); +});