///
///
describe('ContentBlockFinder', function () {
const finder = new ContentBlockFinder();
let testDiv:JQuery;
beforeEach(function () {
testDiv = jQuery('
');
jQuery('body').append(testDiv);
});
afterEach(function () {
testDiv.remove();
});
it('finds a single content block', function () {
testDiv.append('');
const elements:HTMLElement[] = finder.find();
expect(elements.length).toBe(1);
expect(elements[0].attributes.getNamedItem('data-content-path').value).toBe('my-path');
expect(elements[0].attributes.getNamedItem('data-api-key').value).toBe('my-key');
});
it('finds multiple content blocks', function () {
testDiv.append('')
.append('')
.append('');
const elements:HTMLElement[] = finder.find();
expect(elements.length).toBe(3);
const pairs = elements.map((x) => x.attributes).map((x) =>
[x.getNamedItem('data-content-path').value, x.getNamedItem('data-api-key').value]);
expect(pairs).toContain(['my-path', 'my-key']);
expect(pairs).toContain(['other-path', 'my-key']);
expect(pairs).toContain(['xxx-path', 'my-key']);
});
it('finds given content block', function () {
testDiv.append('')
.append('')
.append('');
const elements:HTMLElement[] = finder.find_by('other-path');
expect(elements.length).toBe(1);
expect(elements[0].attributes.getNamedItem('data-content-path').value).toBe('other-path');
expect(elements[0].attributes.getNamedItem('data-api-key').value).toBe('my-key');
});
});