I have a function that returns an array of objects with a title and an image:
import fire from 'assets/svg/fire.svg';
import water from './img/water.svg';
import wind from './img/wind.svg';
const getConfig = (gender) => {
return [
{
title: 'first title',
image: fire
},
{
title: 'second title',
image: gender === 'male' ? wind : water
}
]
}
And I want to create tests to check for the correct file name. For example:
expect(optionsData[0].title).toBe('first title');
expect(optionsData[0].image).toBe('fire.svg');
Didn’t find the correct solution.
The one with creating
module.exports = 'test-file-stub';
in the fileMock.ts will always return the same string, and it is useless if the image depends on the gender.