addin heading to convertPrrByKey2Csv() method
This commit is contained in:
@@ -1,12 +1,19 @@
|
|||||||
class PrrByKey2CsvConverter {
|
class PrrByKey2CsvConverter {
|
||||||
|
|
||||||
static convertPrrByKey2Csv({ prrByKey, keyColumn, prrColumn }) {
|
static convertPrrByKey2Csv(
|
||||||
return PrrByKey2CsvConverter.#convert2Csv(
|
{
|
||||||
{
|
heading,
|
||||||
prrByKey: PrrByKey2CsvConverter.#quoteKeys(prrByKey),
|
columns: { keyColumn, prrColumn },
|
||||||
keyColumn: PrrByKey2CsvConverter.#quote(keyColumn),
|
prrByKey
|
||||||
prrColumn: PrrByKey2CsvConverter.#quote(prrColumn)
|
}
|
||||||
});
|
) {
|
||||||
|
return heading + '\n\n' +
|
||||||
|
PrrByKey2CsvConverter.#convert2Csv(
|
||||||
|
{
|
||||||
|
prrByKey: PrrByKey2CsvConverter.#quoteKeys(prrByKey),
|
||||||
|
keyColumn: PrrByKey2CsvConverter.#quote(keyColumn),
|
||||||
|
prrColumn: PrrByKey2CsvConverter.#quote(prrColumn)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static #quoteKeys(prrByKey) {
|
static #quoteKeys(prrByKey) {
|
||||||
|
|||||||
@@ -38,9 +38,12 @@ class PrrByVaccineTableView {
|
|||||||
[
|
[
|
||||||
PrrByKey2CsvConverter.convertPrrByKey2Csv(
|
PrrByKey2CsvConverter.convertPrrByKey2Csv(
|
||||||
{
|
{
|
||||||
prrByKey: this.#prrByVaccine,
|
heading: '# Symptom: ' + this.#symptom,
|
||||||
keyColumn: 'Vaccine',
|
columns: {
|
||||||
prrColumn: 'Proportional Reporting Ratio'
|
keyColumn: 'Vaccine',
|
||||||
|
prrColumn: 'Proportional Reporting Ratio'
|
||||||
|
},
|
||||||
|
prrByKey: this.#prrByVaccine
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
{ type: 'text/csv' })),
|
{ type: 'text/csv' })),
|
||||||
|
|||||||
@@ -10,14 +10,19 @@ QUnit.module('PrrByKey2CsvConverterTest', function () {
|
|||||||
// When
|
// When
|
||||||
const csv = PrrByKey2CsvConverter.convertPrrByKey2Csv(
|
const csv = PrrByKey2CsvConverter.convertPrrByKey2Csv(
|
||||||
{
|
{
|
||||||
prrByKey: prrByKey,
|
heading: '# Symptom: Acute hepatitis C',
|
||||||
keyColumn: 'Vaccine',
|
columns: {
|
||||||
prrColumn: 'Proportional Reporting Ratio'
|
keyColumn: 'Vaccine',
|
||||||
|
prrColumn: 'Proportional Reporting Ratio'
|
||||||
|
},
|
||||||
|
prrByKey: prrByKey
|
||||||
});
|
});
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
const csvExpected =
|
const csvExpected =
|
||||||
`"Vaccine","Proportional Reporting Ratio"
|
`# Symptom: Acute hepatitis C
|
||||||
|
|
||||||
|
"Vaccine","Proportional Reporting Ratio"
|
||||||
"MM,R",26.17432376240791
|
"MM,R",26.17432376240791
|
||||||
"VARCEL",10.549534724816644`;
|
"VARCEL",10.549534724816644`;
|
||||||
assert.equal(csv, csvExpected);
|
assert.equal(csv, csvExpected);
|
||||||
|
|||||||
Reference in New Issue
Block a user