Skip to content

Commit

Permalink
add tests for json formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
bmesuere committed Aug 1, 2024
1 parent 7da1e02 commit ec28bfe
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/formatters/json_formatter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { FormatterFactory } from "../../lib/formatters/formatter_factory";
import { TestObject } from "./test_object";

const formatter = FormatterFactory.getFormatter("json");

test('test header', () => {
const object = [TestObject.testObject(), TestObject.testObject()];
expect(formatter.header(object)).toBe("[");
});

test('test footer', () => {
expect(formatter.footer()).toBe("]\n");
});

test('test convert', () => {
const object = [TestObject.testObject()];
const json = TestObject.asJson();

expect(formatter.convert(object, true)).toBe(json);
expect(formatter.convert(object, false)).toBe(`,${json}`);
});

test('test format with fasta', () => {
//const fasta = [['>test', '5']];
//const object = [TestObject.testObject()];
//const json = '{"fasta_header":">test","integer":5,"string":"string","list":["a",2,false]}';
//expect(formatter.format(object, fasta, true)).toBe(json);
});

0 comments on commit ec28bfe

Please sign in to comment.