diff options
Diffstat (limited to 'spec/frontend/lib/utils/dom_utils_spec.js')
-rw-r--r-- | spec/frontend/lib/utils/dom_utils_spec.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/dom_utils_spec.js b/spec/frontend/lib/utils/dom_utils_spec.js index d6bac935970..172f8972653 100644 --- a/spec/frontend/lib/utils/dom_utils_spec.js +++ b/spec/frontend/lib/utils/dom_utils_spec.js @@ -10,6 +10,7 @@ import { getParents, getParentByTagName, setAttributes, + replaceCommentsWith, } from '~/lib/utils/dom_utils'; const TEST_MARGIN = 5; @@ -263,4 +264,21 @@ describe('DOM Utils', () => { expect(getContentWrapperHeight('.does-not-exist')).toBe(''); }); }); + + describe('replaceCommentsWith', () => { + let div; + beforeEach(() => { + div = document.createElement('div'); + }); + + it('replaces the comments in a DOM node with an element', () => { + div.innerHTML = '<h1> hi there <!-- some comment --> <p> <!-- another comment -->'; + + replaceCommentsWith(div, 'comment'); + + expect(div.innerHTML).toBe( + '<h1> hi there <comment> some comment </comment> <p> <comment> another comment </comment></p></h1>', + ); + }); + }); }); |