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

Commit

Permalink
Merge pull request #2978 from adobe/jasonsanjose/fix-editor-tests
Browse files Browse the repository at this point in the history
fix broken Editor unit tests
  • Loading branch information
RaymondLim committed Feb 27, 2013
2 parents 1207755 + 1483b4a commit 88cf9c4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/spec/Editor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,25 @@ define(function (require, exports, module) {
LanguageManager = require("language/LanguageManager");

var langNames = {
css: {mode: "css", lang: "CSS"},
javascript: {mode: "javascript", lang: "JavaScript"},
html: {mode: "html", lang: "HTML"}
css: {mode: "css", langName: "CSS"},
javascript: {mode: "javascript", langName: "JavaScript"},
html: {mode: "html", langName: "HTML"},
unknown: {mode: null, langName: "Text"}
};

function compareMode(expected, actual) {
if (typeof actual === "string") {
return actual === expected;
} else if (actual === null) {
return expected === null;
}

return actual.name === expected;
}

function expectModeAndLang(editor, lang) {
expect(editor.getModeForSelection()).toSpecifyModeNamed(lang.mode);
expect(editor.getLanguageForSelection()).toBe(lang.lang);
expect(editor.getLanguageForSelection().name).toBe(lang.langName);
}

describe("Editor", function () {
Expand Down Expand Up @@ -207,7 +210,7 @@ define(function (require, exports, module) {

// Mode for range - mix of modes
myEditor.setSelection({line: 2, ch: 4}, {line: 3, ch: 7});
expectModeAndLang(myEditor, null);
expectModeAndLang(myEditor, langNames.unknown);

// Mode for range - mix of modes where start & endpoints are same mode
// Known limitation of getModeForSelection() that it does not spot where the mode
Expand Down

0 comments on commit 88cf9c4

Please sign in to comment.