Skip to content

Commit

Permalink
ADD addon-contexts: tests on serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo Y. Li committed Apr 24, 2019
1 parent d71d9de commit d8ca8e0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions addons/contexts/src/shared/serializers.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit d8ca8e0

Please sign in to comment.