Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 90c878c

Browse files
author
Marcel Gerber
committed
Add test case
1 parent 0cc5302 commit 90c878c

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/extensions/default/UrlCodeHints/testfiles/test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
<a href='/'>Site-root relative: root folder</a>
2424
<a href='test2.html'>Results</a>
2525
<video poster=''>Results</video>
26+
<img src='subfolder/chevron.png'>
2627
</body>
2728
</html>

src/extensions/default/UrlCodeHints/unittests.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,34 @@ define(function (require, exports, module) {
620620
});
621621
});
622622

623+
it("should completely replace file in HTML", function () {
624+
var pos1 = { line: 25, ch: 11 },
625+
pos2 = { line: 25, ch: 27 },
626+
pos3 = { line: 25, ch: 34 };
627+
628+
runs(function () {
629+
testEditor.setCursorPos(pos2);
630+
hintsObj = null;
631+
expectAsyncHints(UrlCodeHints.hintProvider);
632+
});
633+
634+
runs(function () {
635+
expect(hintsObj).toBeTruthy();
636+
expect(hintsObj.hints).toBeTruthy();
637+
expect(hintsObj.hints.length).toBe(1);
638+
expect(hintsObj.hints[0]).toBe("subfolder/chevron.png");
639+
640+
// False indicates hints were closed after insertion
641+
expect(UrlCodeHints.hintProvider.insertHint(hintsObj.hints[0])).toBe(false);
642+
643+
// File name was completely replaced, not just appended to
644+
expect(testDocument.getRange(pos1, pos3)).toEqual("'subfolder/chevron.png'");
645+
646+
// Cursor was moved past closing single-quote
647+
expect(testEditor.getCursorPos()).toEqual(pos3);
648+
});
649+
});
650+
623651
it("should insert filtered folder in HTML", function () {
624652
var pos1 = { line: 23, ch: 11 },
625653
pos2 = { line: 23, ch: 14 },

0 commit comments

Comments
 (0)