test(Elife): Add dataProvider test
@@ -83,13 +83,24 @@ describe('data Provider ', () => {
})
describe('getArticleTitle', () => {
- it('it returns the correct text of a title', () => {
+ it('returns the correct text of a title', () => {
const mockData =
'Replication Study: Transcriptional amplification in tumor cells with elevated c-Myc'
body.innerHTML = `<div itemprop="headline">${mockData}</div>`
expect(dataProvider.getArticleTitle()).toEqual(mockData)
})
+ it('normalises any whitespace found', () => {
+ const mockDataWithExtraWhitespace =
+ 'Replication Study: Transcriptional \n amplification in \n\n tumor cells with elevated c-Myc'
+ const mockDataWithoutExtraWhitespace =
+ 'Replication Study: Transcriptional amplification in tumor cells with elevated c-Myc'
+ body.innerHTML = `<div itemprop="headline">${mockDataWithExtraWhitespace}</div>`
+ expect(dataProvider.getArticleTitle()).toEqual(
+ mockDataWithoutExtraWhitespace
+ )
+ })
+
it('omits any elements from the text it returns', () => {
const mockDataWithMarkup =
'Replication Study: Transcriptional amplification in <sup>tumor cells</sup> with elevated c-Myc'
