Skip to content

Commit

Permalink
[Feature] Add unit test for RNANews (#14)
Browse files Browse the repository at this point in the history
* Implement test for loading RNANews
* Implement test for RNANews response validation
  • Loading branch information
Eskils authored Aug 19, 2024
1 parent 51a3fa4 commit ac39f8c
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions test/unit-tests/RNANews/RNANewsConverter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import * as Assert from 'node:assert/strict';
import * as MC from '../../../code/connectors-morningstar.src';
import RNANewsJSON from '../../../src/RNANews/RNANewsJSON';

export async function rnaNewsLoad (
api: MC.Shared.MorningstarAPIOptions
) {
const connector = new MC.RNANewsConnector({
api,
security: {
id: 'GB00BLGZ9862',
idType: 'ISIN'
},
startDate: '2023-05-13',
endDate: '2023-05-23'
});

Assert.ok(
connector instanceof MC.RNANewsConnector,
'Connector should be instance of RNANewsConnector class.'
);

Assert.ok(
connector.converter instanceof
MC.RNANewsConverter,
'Converter should be instance of RNANewsConverter.'
);

await connector.load();

Assert.deepStrictEqual(
connector.table.getColumnNames(),
['Day', 'Title', 'Source', 'Type'],
'Connector table should exist of expected columns.'
);

Assert.strictEqual(
connector.table.getRowCount(),
10,
'Connector table should have one expected dividend row.'
);

}

export function rnaNewsValidation () {

const day = '1723766400000';
const item = ['LSE20240816070005_5311334', 'Transaction in Own Shares', 'RNS', 'POS'];

const mockResponse = [
{
day: day,
items: [item]
}
];

Assert.ok(
RNANewsJSON.isResponse(mockResponse),
'Mock response should be considered a valid response'
);
}

0 comments on commit ac39f8c

Please sign in to comment.