Skip to content

Commit e7af923

Browse files
committed
fix: code inspection integ tests
1 parent 3decfc9 commit e7af923

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

test/spec/CodeInspection-integ-test.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,20 +558,31 @@ define(function (require, exports, module) {
558558
expect(marks.find('span').hasClass('line-icon-problem_type_info')).toBeTrue();
559559
});
560560

561+
function _hasClass(marks, className) {
562+
let errorFound = false;
563+
for(let mark of marks) {
564+
if(mark.className === className){
565+
errorFound = true;
566+
break;
567+
}
568+
}
569+
return errorFound;
570+
}
571+
561572
async function _verifyMixOfErrors(chw, che, chm, numMarksExpected = 1) {
562573
let codeInspector1 = createCodeInspector("javascript linter 1", {
563574
errors: [
564575
{
565576
pos: { line: 1, ch: chw },
566-
message: "Some errors here and there",
577+
message: "Some warnings here and there",
567578
type: CodeInspection.Type.WARNING
568579
}, {
569580
pos: { line: 1, ch: che },
570581
message: "Some errors here and there",
571582
type: CodeInspection.Type.ERROR
572583
}, {
573584
pos: { line: 1, ch: chm },
574-
message: "Some errors here and there",
585+
message: "Some meta here and there",
575586
type: CodeInspection.Type.META
576587
}
577588
]
@@ -583,26 +594,27 @@ define(function (require, exports, module) {
583594
expect($("#problems-panel").is(":visible")).toBe(true);
584595
let marks = EditorManager.getActiveEditor().getAllMarks("codeInspector");
585596
expect(marks.length).toBe(numMarksExpected);
586-
expect(marks[0].className).toBe("editor-text-fragment-error");
597+
598+
expect(_hasClass(marks, "editor-text-fragment-error")).toBe(true);
587599
}
588600

589-
it("should underline errors only if warnings and info present in the same location", async function () {
590-
await _verifyMixOfErrors(1, 2, 3);
601+
it("should have errors if warnings and info present in the same location", async function () {
602+
await _verifyMixOfErrors(1, 2, 3, 3);
591603
});
592604

593605
it("should show errors icon only in gutter if warn and info also present on line", async function () {
594-
await _verifyMixOfErrors(1, 2, 3);
606+
await _verifyMixOfErrors(1, 2, 3, 3);
595607

596608
let marks = $(EditorManager.getActiveEditor().getGutterMarker(1, CodeInspection.CODE_INSPECTION_GUTTER));
597609
expect(marks.find('span').hasClass('line-icon-problem_type_error')).toBeTrue();
598610
});
599611

600612
it("should show errors, warning or info underline under text in editor appropriately", async function () {
601-
await _verifyMixOfErrors(1, 2, 10, 2);
613+
await _verifyMixOfErrors(1, 2, 10, 3);
602614

603615
let marks = EditorManager.getActiveEditor().getAllMarks("codeInspector");
604-
expect(marks[0].className).toBe("editor-text-fragment-error");
605-
expect(marks[1].className).toBe("editor-text-fragment-info");
616+
expect(_hasClass(marks, "editor-text-fragment-error")).toBe(true);
617+
expect(_hasClass(marks, "editor-text-fragment-info")).toBe(true);
606618
});
607619

608620
it("should ignore async results from previous file", async function () {

0 commit comments

Comments
 (0)