(link, href)
| 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', |
no test coverage detected
searching dependent graphs…