const { insertErms } = require('./insert-erms');
describe('insertErms helper', () => {
const code = `
Hello World
CatPhotoApp
Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.
Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.
`;
it('should throw error if erm is undefined', () => {
expect(() => {
insertErms(code);
}).toThrow();
});
it('should throw error if erm length is less than 2', () => {
const items = [[], [1]];
items.forEach(item => {
expect(() => {
insertErms(code, item);
}).toThrow();
});
});
it('should update code with markers if provided', () => {
const newCode = `--fcc-editable-region--
Hello World
CatPhotoApp
Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.
Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.
--fcc-editable-region--
`;
expect(insertErms(code, [0, 7])).toEqual(newCode);
});
it('should update code with 2 markers if more are provided', () => {
const newCode = `Hello World
--fcc-editable-region--
CatPhotoApp
--fcc-editable-region--
Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.
Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.
`;
expect(insertErms(code, [2, 4, 6, 7])).toEqual(newCode);
});
});