Skip to content

Commit

Permalink
test(searlie): validate data while decoding with headers
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhck committed Nov 1, 2019
1 parent 2b72812 commit 3703fb8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/Searilie.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,22 @@ describe("Searilie", () => {
});
});
describe("decode using headers", () => {
const adapter: IAdapter = {
deserialize: jest.fn(() => [{a: 2}]),
getIdentifier: jest.fn(() => "A")
} as any;
const serializer = new Searilie(adapter);
expect(serializer.decodeUsingHeaders(`Aa,${INTEGER_IDENTIFIER}b:h2`)).toStrictEqual([{a: 2}]);
it("should throw error if wrong adapter", () => {
const adapter: IAdapter = {
deserialize: jest.fn(() => [{a: 2}]),
getIdentifier: jest.fn(() => "Z")
} as any;
const serializer = new Searilie(adapter);
expect(() => serializer.decodeUsingHeaders(`Aa,${INTEGER_IDENTIFIER}b:h2`)).toThrow("adapter mismatched");
});
it("should be able to decode properly", () => {
const adapter: IAdapter = {
deserialize: jest.fn(() => [{a: 2}]),
getIdentifier: jest.fn(() => "A")
} as any;
const serializer = new Searilie(adapter);
expect(serializer.decodeUsingHeaders(`Aa,${INTEGER_IDENTIFIER}b:h2`)).toStrictEqual([{a: 2}]);
});
});
describe("decode and encode with headers", () => {
it("should decode and encode properly", () => {
Expand Down

0 comments on commit 3703fb8

Please sign in to comment.