I am receiving this table on my tests reports
-----------------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------------------------|---------|----------|---------|---------|-------------------
All files | 96.15 | 49.59 | 100 | 96.15 |
subNavBackgrounds.js | 100 | 25.87 | 100 | 100 | 34-161
-----------------------------|---------|----------|---------|---------|-------------------
It is a simple function. This is the file
subNavBackgrounds.js
export const getSubNavObject = (color = '#000000', image = null) => {
return { color, image };
};
export function getSubNavBackgrounds(image) {
const isDesktop = getDevice(Store) === 'desktop';
// this is a list with around 400 items
return {
// let's say the line below is the first one uncovered
action: getSubNavObject('#000', image || (isDesktop ? 'a.jpg' : 'b.jpg'), // line 34
// and so on
// let's say the line below is the last one uncovered
comedy: getSubNavObject('#fff', image || (isDesktop ? 'c.jpg' : 'd.jpg'), // line 161
}
};
So basically in that report, what it says is that the lines (34-161) between the return method of the function getSubNavBackgrounds are uncovered by the tests.
The tests I wrote are not working at all:
import { getSubNavBackgrounds } from './subNavBackgrounds';
// I removed all of the items in the list and only one left on the line 34
describe('Programs subNavBackgrounds', () => {
it('test uncovered lines', () => {
expect(getSubNavBackgrounds('desktop.jpg')).toStrictEqual({ 'action': { color: '#000', image: 'desktop.jpg' } });
expect(getSubNavBackgrounds()).toStrictEqual({ 'action': { color: '#4E4E4E', image: "https://someS3.bucket.image.jpg" } });
});
});
With those tests I still get the same result. Any ideass?