-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { FormatterFactory } from "../../lib/formatters/formatter_factory"; | ||
import { TestObject } from "./test_object"; | ||
|
||
const formatter = FormatterFactory.getFormatter("csv"); | ||
|
||
test('test header', () => { | ||
const fasta = [["peptide", ">test"]]; | ||
const object = [TestObject.testObject(), TestObject.testObject()]; | ||
expect(formatter.header(object)).toBe(TestObject.asCsvHeader()); | ||
//expect(formatter.header(object, fasta)).toBe(`fasta_header,${TestObject.asCsvHeader()}`); | ||
}); | ||
|
||
test('test footer', () => { | ||
expect(formatter.footer()).toBe(""); | ||
}); | ||
|
||
test('test convert', () => { | ||
const object = [TestObject.testObject(), TestObject.testObject()]; | ||
const csv = [TestObject.asCsv(), TestObject.asCsv(), ""].join("\n"); | ||
|
||
expect(formatter.convert(object, true)).toBe(csv); | ||
expect(formatter.convert(object, false)).toBe(csv); | ||
}); | ||
|
||
test('test format with fasta', () => { | ||
const fasta = [['>test', '5']]; | ||
const object = [TestObject.testObject(), TestObject.testObject()]; | ||
const csv = [`>test,${TestObject.asCsv()}`, TestObject.asCsv(), ""].join("\n"); | ||
//expect(formatter.format(object, fasta, false)).toBe(csv); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { FormatterFactory } from "../../lib/formatters/formatter_factory"; | ||
|
||
test('test if default formatter is csv', async () => { | ||
const formatter = FormatterFactory.getFormatter("foo"); | ||
expect(formatter.constructor.name).toBe("CSVFormatter"); | ||
}); | ||
|
||
test('test if csv formatter is csv', async () => { | ||
const formatter = FormatterFactory.getFormatter("csv"); | ||
expect(formatter.constructor.name).toBe("CSVFormatter"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export class TestObject { | ||
static testObject() { | ||
return { "integer": 5, "string": "string", "list": ["a", 2, false] }; | ||
} | ||
|
||
static asJson() { | ||
return '{"integer":5,"string":"string","list":["a",2,false]}'; | ||
} | ||
|
||
static asXml() { | ||
return '<integer>5</integer><string>string</string><list><item>a</item><item>2</item><item>false</item></list>'; | ||
} | ||
|
||
static asCsv() { | ||
return '5,string,"[""a"",2,false]"'; | ||
} | ||
|
||
static asCsvHeader() { | ||
return "integer,string,list\n"; | ||
} | ||
} |