Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* vim: set ts=2 et sw=2 tw=80: */
2 /* Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/ */
5 "use strict";
7 function test() {
8 waitForExplicitFinish();
9 setup((ed, win) => {
10 // appendTo
11 let src = win.document.querySelector("iframe").getAttribute("src");
12 ok(~src.indexOf(".CodeMirror"), "correct iframe is there");
14 // getOption/setOption
15 ok(ed.getOption("styleActiveLine"), "getOption works");
16 ed.setOption("styleActiveLine", false);
17 ok(!ed.getOption("styleActiveLine"), "setOption works");
19 // Language modes
20 is(ed.getMode(), Editor.modes.text, "getMode");
21 ed.setMode(Editor.modes.js);
22 is(ed.getMode(), Editor.modes.js, "setMode");
24 // Content
25 is(ed.getText(), "Hello.", "getText");
26 ed.setText("Hi.\nHow are you?");
27 is(ed.getText(), "Hi.\nHow are you?", "setText");
28 is(ed.getText(1), "How are you?", "getText(num)");
29 is(ed.getText(5), "", "getText(num) when num is out of scope");
31 ed.replaceText("YOU", { line: 1, ch: 8 }, { line: 1, ch: 11 });
32 is(ed.getText(1), "How are YOU?", "replaceText(str, from, to)");
33 ed.replaceText("you?", { line: 1, ch: 8 });
34 is(ed.getText(1), "How are you?", "replaceText(str, from)");
35 ed.replaceText("Hello.");
36 is(ed.getText(), "Hello.", "replaceText(str)");
38 ed.insertText(", sir/madam", { line: 0, ch: 5});
39 is(ed.getText(), "Hello, sir/madam.", "insertText");
41 // Add-ons
42 ed.extend({ whoami: () => "Anton", whereami: () => "Mozilla" });
43 is(ed.whoami(), "Anton", "extend/1");
44 is(ed.whereami(), "Mozilla", "extend/2");
46 // Line classes
47 ed.setText("Hello!\nHow are you?");
48 ok(!ed.hasLineClass(0, "test"), "no test line class");
49 ed.addLineClass(0, "test");
50 ok(ed.hasLineClass(0, "test"), "test line class is there");
51 ed.removeLineClass(0, "test");
52 ok(!ed.hasLineClass(0, "test"), "test line class is gone");
54 // Font size
55 let size = ed.getFontSize();
56 is("number", typeof size, "we have the default font size");
57 ed.setFontSize(ed.getFontSize() + 1);
58 is(ed.getFontSize(), size + 1, "new font size was set");
60 teardown(ed, win);
61 });
62 }