import {syncIssueMainContentTimelineItems} from './repo-issue-sidebar-combolist.ts';
import {createElementFromHTML} from '../utils/dom.ts';
describe('syncIssueMainContentTimelineItems', () => {
test('InsertNew', () => {
const oldContent = createElementFromHTML(`
`);
const newContent = createElementFromHTML(`
`);
syncIssueMainContentTimelineItems(oldContent, newContent);
expect(oldContent.innerHTML.replace(/>\s+<').trim()).toBe(
`First
` +
`New
` +
``,
);
});
test('Sync', () => {
const oldContent = createElementFromHTML(`
First
Item 1
Item 2
Item 3
Item 4
Other
`);
const newContent = createElementFromHTML(`
`);
syncIssueMainContentTimelineItems(oldContent, newContent);
// Item 1 won't be replaced because it's not an event
// Item 2 will be replaced with New 2
// Item 3 will be kept because it's not in new content
// Item 4 will be removed because it's not in new content, and it's an event
// New X will be inserted at the end of timeline items (before timeline-comments-end)
expect(oldContent.innerHTML.replace(/>\s+<').trim()).toBe(
`First
` +
`Item 1
` +
`New 2
` +
`Item 3
` +
`New X
` +
`` +
`Other
`,
);
});
});