MCPcopy
hub / github.com/yabwe/medium-editor / generateLinkTest

Function generateLinkTest

spec/auto-link.spec.js:146–164  ·  view source on GitHub ↗
(link, href)

Source from the content-addressed store, hash-verified

144 }
145
146 function generateLinkTest(link, href) {
147 return function () {
148 var selection = window.getSelection(),
149 newRange = document.createRange();
150 this.el.innerHTML = '<p>' + link + ' </p>';
151 selection.removeAllRanges();
152 newRange.setStart(this.el.firstChild.childNodes[0], link.length + 1);
153 newRange.setEnd(this.el.firstChild.childNodes[0], link.length + 1);
154 selection.addRange(newRange);
155
156 triggerAutolinking(this.el);
157
158 var anchors = this.el.getElementsByTagName('a');
159 expect(anchors.length).toBe(1);
160 expect('href: ' + anchors[0].getAttribute('href')).toBe('href: ' + href);
161 expect('Text content: ' + anchors[0].textContent).toBe('Text content: ' + link);
162 expect(anchors[0].firstChild.getAttribute('data-auto-link')).toBe('true');
163 };
164 }
165
166 links.forEach(function (link) {
167 it('should auto-link "' + link + '" when typed in',

Callers 1

auto-link.spec.jsFile · 0.85

Calls 1

triggerAutolinkingFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…