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

Commit

Permalink
add tests for filtered insertions
Browse files Browse the repository at this point in the history
  • Loading branch information
redmunds committed May 3, 2014
1 parent 6d6bfc9 commit 4dc4f23
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions src/extensions/default/UrlCodeHints/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,54 @@ define(function (require, exports, module) {
});
});

it("should insert filtered folder in HTML", function () {
var pos1 = { line: 23, ch: 11 },
pos2 = { line: 23, ch: 14 },
pos3 = { line: 23, ch: 31 };

runs(function () {
testDocument.replaceRange("sub", pos1, pos1);
testEditor.setCursorPos(pos2);
hintsObj = null;
expectAsyncHints(UrlCodeHints.hintProvider);
});

runs(function () {
expect(hintsObj).toBeTruthy();
expect(hintsObj.hints).toBeTruthy();
expect(hintsObj.hints.length).toBe(1);
expect(hintsObj.hints[0]).toBe("subfolder/");

// Partially existing folder was inserted correctly
UrlCodeHints.hintProvider.insertHint(hintsObj.hints[0]);
expect(testDocument.getRange(pos1, pos3)).toEqual("subfolder/test2.html");
});
});

it("should replace filtered file in HTML", function () {
var pos1 = { line: 23, ch: 11 },
pos2 = { line: 23, ch: 14 },
pos3 = { line: 23, ch: 21 };

runs(function () {
testDocument.replaceRange("tes", pos1, pos1);
testEditor.setCursorPos(pos2);
hintsObj = null;
expectAsyncHints(UrlCodeHints.hintProvider);
});

runs(function () {
expect(hintsObj).toBeTruthy();
expect(hintsObj.hints).toBeTruthy();
expect(hintsObj.hints.length).toBe(1);
expect(hintsObj.hints[0]).toBe("test.html");

// Partially existing file was replaced correctly
UrlCodeHints.hintProvider.insertHint(hintsObj.hints[0]);
expect(testDocument.getRange(pos1, pos3)).toEqual("test.html'");
});
});

it("should insert folder and replace file in CSS", function () {
var pos1 = { line: 10, ch: 24 },
pos2 = { line: 10, ch: 34 },
Expand Down Expand Up @@ -640,6 +688,54 @@ define(function (require, exports, module) {
});
});

it("should insert filtered folder in CSS", function () {
var pos1 = { line: 10, ch: 24 },
pos2 = { line: 10, ch: 27 },
pos3 = { line: 10, ch: 43 };

runs(function () {
testDocument.replaceRange("sub", pos1, pos1);
testEditor.setCursorPos(pos2);
hintsObj = null;
expectAsyncHints(UrlCodeHints.hintProvider);
});

runs(function () {
expect(hintsObj).toBeTruthy();
expect(hintsObj.hints).toBeTruthy();
expect(hintsObj.hints.length).toBe(1);
expect(hintsObj.hints[0]).toBe("subfolder/");

// Partially existing folder was inserted correctly
UrlCodeHints.hintProvider.insertHint(hintsObj.hints[0]);
expect(testDocument.getRange(pos1, pos3)).toEqual("subfolder/dummy.jpg");
});
});

it("should replace filtered file in CSS", function () {
var pos1 = { line: 10, ch: 24 },
pos2 = { line: 10, ch: 27 },
pos3 = { line: 10, ch: 34 };

runs(function () {
testDocument.replaceRange("tes", pos1, pos1);
testEditor.setCursorPos(pos2);
hintsObj = null;
expectAsyncHints(UrlCodeHints.hintProvider);
});

runs(function () {
expect(hintsObj).toBeTruthy();
expect(hintsObj.hints).toBeTruthy();
expect(hintsObj.hints.length).toBe(1);
expect(hintsObj.hints[0]).toBe("test.html");

// Partially existing file was replaced correctly
UrlCodeHints.hintProvider.insertHint(hintsObj.hints[0]);
expect(testDocument.getRange(pos1, pos3)).toEqual("test.html)");
});
});

it("should collapse consecutive path separators when inserting folder in HTML", function () {
var pos1 = { line: 22, ch: 11 },
pos2 = { line: 22, ch: 22 };
Expand Down

0 comments on commit 4dc4f23

Please sign in to comment.