diff --git a/tests/formatters/json_formatter.test.ts b/tests/formatters/json_formatter.test.ts new file mode 100644 index 00000000..c4e80648 --- /dev/null +++ b/tests/formatters/json_formatter.test.ts @@ -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); +});