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); + }); +});