Skip to content

Commit

Permalink
Issue #4: add frontend unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
idrissneumann committed Dec 28, 2023
1 parent bc63730 commit 34a70c7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { extractJsonPayload } from "utils";

describe('Test utils.extractJsonPayload', () => {
it('Extract valid JSON', () => {
const result = extractJsonPayload('Hey {"foo": "bar"}')
expect(result).toEqual({
foo: "bar"
});
});

it('Extract non valid JSON', () => {
const result = extractJsonPayload('Hey {"foo": invalid}')
expect(result).toEqual(null);
});

it('Extract multiple valid JSONs (not supported)', () => {
const result = extractJsonPayload('Hey {"foo": "bar"} {"foo2": "bar2"}')
expect(result).toEqual(null);
});
});

0 comments on commit 34a70c7

Please sign in to comment.