How to use pos method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

test.js

Source:test.js Github

copy

Full Screen

1var Pos = CodeMirror.Pos;2CodeMirror.defaults.rtlMoveVisually = true;3function forEach(arr, f) {4 for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);5}6function addDoc(cm, width, height) {7 var content = [], line = "";8 for (var i = 0; i < width; ++i) line += "x";9 for (var i = 0; i < height; ++i) content.push(line);10 cm.setValue(content.join("\n"));11}12function byClassName(elt, cls) {13 if (elt.getElementsByClassName) return elt.getElementsByClassName(cls);14 var found = [], re = new RegExp("\\b" + cls + "\\b");15 function search(elt) {16 if (elt.nodeType == 3) return;17 if (re.test(elt.className)) found.push(elt);18 for (var i = 0, e = elt.childNodes.length; i < e; ++i)19 search(elt.childNodes[i]);20 }21 search(elt);22 return found;23}24var ie_lt8 = /MSIE [1-7]\b/.test(navigator.userAgent);25var ie_lt9 = /MSIE [1-8]\b/.test(navigator.userAgent);26var mac = /Mac/.test(navigator.platform);27var phantom = /PhantomJS/.test(navigator.userAgent);28var opera = /Opera\/\./.test(navigator.userAgent);29var opera_version = opera && navigator.userAgent.match(/Version\/(\d+\.\d+)/);30if (opera_version) opera_version = Number(opera_version);31var opera_lt10 = opera && (!opera_version || opera_version < 10);32namespace = "core_";33test("core_fromTextArea", function() {34 var te = document.getElementById("code");35 te.value = "CONTENT";36 var cm = CodeMirror.fromTextArea(te);37 is(!te.offsetHeight);38 eq(cm.getValue(), "CONTENT");39 cm.setValue("foo\nbar");40 eq(cm.getValue(), "foo\nbar");41 cm.save();42 is(/^foo\r?\nbar$/.test(te.value));43 cm.setValue("xxx");44 cm.toTextArea();45 is(te.offsetHeight);46 eq(te.value, "xxx");47});48testCM("getRange", function(cm) {49 eq(cm.getLine(0), "1234");50 eq(cm.getLine(1), "5678");51 eq(cm.getLine(2), null);52 eq(cm.getLine(-1), null);53 eq(cm.getRange(Pos(0, 0), Pos(0, 3)), "123");54 eq(cm.getRange(Pos(0, -1), Pos(0, 200)), "1234");55 eq(cm.getRange(Pos(0, 2), Pos(1, 2)), "34\n56");56 eq(cm.getRange(Pos(1, 2), Pos(100, 0)), "78");57}, {value: "1234\n5678"});58testCM("replaceRange", function(cm) {59 eq(cm.getValue(), "");60 cm.replaceRange("foo\n", Pos(0, 0));61 eq(cm.getValue(), "foo\n");62 cm.replaceRange("a\nb", Pos(0, 1));63 eq(cm.getValue(), "fa\nboo\n");64 eq(cm.lineCount(), 3);65 cm.replaceRange("xyzzy", Pos(0, 0), Pos(1, 1));66 eq(cm.getValue(), "xyzzyoo\n");67 cm.replaceRange("abc", Pos(0, 0), Pos(10, 0));68 eq(cm.getValue(), "abc");69 eq(cm.lineCount(), 1);70});71testCM("selection", function(cm) {72 cm.setSelection(Pos(0, 4), Pos(2, 2));73 is(cm.somethingSelected());74 eq(cm.getSelection(), "11\n222222\n33");75 eqPos(cm.getCursor(false), Pos(2, 2));76 eqPos(cm.getCursor(true), Pos(0, 4));77 cm.setSelection(Pos(1, 0));78 is(!cm.somethingSelected());79 eq(cm.getSelection(), "");80 eqPos(cm.getCursor(true), Pos(1, 0));81 cm.replaceSelection("abc", "around");82 eq(cm.getSelection(), "abc");83 eq(cm.getValue(), "111111\nabc222222\n333333");84 cm.replaceSelection("def", "end");85 eq(cm.getSelection(), "");86 eqPos(cm.getCursor(true), Pos(1, 3));87 cm.setCursor(Pos(2, 1));88 eqPos(cm.getCursor(true), Pos(2, 1));89 cm.setCursor(1, 2);90 eqPos(cm.getCursor(true), Pos(1, 2));91}, {value: "111111\n222222\n333333"});92testCM("extendSelection", function(cm) {93 cm.setExtending(true);94 addDoc(cm, 10, 10);95 cm.setSelection(Pos(3, 5));96 eqPos(cm.getCursor("head"), Pos(3, 5));97 eqPos(cm.getCursor("anchor"), Pos(3, 5));98 cm.setSelection(Pos(2, 5), Pos(5, 5));99 eqPos(cm.getCursor("head"), Pos(5, 5));100 eqPos(cm.getCursor("anchor"), Pos(2, 5));101 eqPos(cm.getCursor("start"), Pos(2, 5));102 eqPos(cm.getCursor("end"), Pos(5, 5));103 cm.setSelection(Pos(5, 5), Pos(2, 5));104 eqPos(cm.getCursor("head"), Pos(2, 5));105 eqPos(cm.getCursor("anchor"), Pos(5, 5));106 eqPos(cm.getCursor("start"), Pos(2, 5));107 eqPos(cm.getCursor("end"), Pos(5, 5));108 cm.extendSelection(Pos(3, 2));109 eqPos(cm.getCursor("head"), Pos(3, 2));110 eqPos(cm.getCursor("anchor"), Pos(5, 5));111 cm.extendSelection(Pos(6, 2));112 eqPos(cm.getCursor("head"), Pos(6, 2));113 eqPos(cm.getCursor("anchor"), Pos(5, 5));114 cm.extendSelection(Pos(6, 3), Pos(6, 4));115 eqPos(cm.getCursor("head"), Pos(6, 4));116 eqPos(cm.getCursor("anchor"), Pos(5, 5));117 cm.extendSelection(Pos(0, 3), Pos(0, 4));118 eqPos(cm.getCursor("head"), Pos(0, 3));119 eqPos(cm.getCursor("anchor"), Pos(5, 5));120 cm.extendSelection(Pos(4, 5), Pos(6, 5));121 eqPos(cm.getCursor("head"), Pos(6, 5));122 eqPos(cm.getCursor("anchor"), Pos(4, 5));123 cm.setExtending(false);124 cm.extendSelection(Pos(0, 3), Pos(0, 4));125 eqPos(cm.getCursor("head"), Pos(0, 3));126 eqPos(cm.getCursor("anchor"), Pos(0, 4));127});128testCM("lines", function(cm) {129 eq(cm.getLine(0), "111111");130 eq(cm.getLine(1), "222222");131 eq(cm.getLine(-1), null);132 cm.replaceRange("", Pos(1, 0), Pos(2, 0))133 cm.replaceRange("abc", Pos(1, 0), Pos(1));134 eq(cm.getValue(), "111111\nabc");135}, {value: "111111\n222222\n333333"});136testCM("indent", function(cm) {137 cm.indentLine(1);138 eq(cm.getLine(1), " blah();");139 cm.setOption("indentUnit", 8);140 cm.indentLine(1);141 eq(cm.getLine(1), "\tblah();");142 cm.setOption("indentUnit", 10);143 cm.setOption("tabSize", 4);144 cm.indentLine(1);145 eq(cm.getLine(1), "\t\t blah();");146}, {value: "if (x) {\nblah();\n}", indentUnit: 3, indentWithTabs: true, tabSize: 8});147testCM("indentByNumber", function(cm) {148 cm.indentLine(0, 2);149 eq(cm.getLine(0), " foo");150 cm.indentLine(0, -200);151 eq(cm.getLine(0), "foo");152 cm.setSelection(Pos(0, 0), Pos(1, 2));153 cm.indentSelection(3);154 eq(cm.getValue(), " foo\n bar\nbaz");155}, {value: "foo\nbar\nbaz"});156test("core_defaults", function() {157 var defsCopy = {}, defs = CodeMirror.defaults;158 for (var opt in defs) defsCopy[opt] = defs[opt];159 defs.indentUnit = 5;160 defs.value = "uu";161 defs.indentWithTabs = true;162 defs.tabindex = 55;163 var place = document.getElementById("testground"), cm = CodeMirror(place);164 try {165 eq(cm.getOption("indentUnit"), 5);166 cm.setOption("indentUnit", 10);167 eq(defs.indentUnit, 5);168 eq(cm.getValue(), "uu");169 eq(cm.getOption("indentWithTabs"), true);170 eq(cm.getInputField().tabIndex, 55);171 }172 finally {173 for (var opt in defsCopy) defs[opt] = defsCopy[opt];174 place.removeChild(cm.getWrapperElement());175 }176});177testCM("lineInfo", function(cm) {178 eq(cm.lineInfo(-1), null);179 var mark = document.createElement("span");180 var lh = cm.setGutterMarker(1, "FOO", mark);181 var info = cm.lineInfo(1);182 eq(info.text, "222222");183 eq(info.gutterMarkers.FOO, mark);184 eq(info.line, 1);185 eq(cm.lineInfo(2).gutterMarkers, null);186 cm.setGutterMarker(lh, "FOO", null);187 eq(cm.lineInfo(1).gutterMarkers, null);188 cm.setGutterMarker(1, "FOO", mark);189 cm.setGutterMarker(0, "FOO", mark);190 cm.clearGutter("FOO");191 eq(cm.lineInfo(0).gutterMarkers, null);192 eq(cm.lineInfo(1).gutterMarkers, null);193}, {value: "111111\n222222\n333333"});194testCM("coords", function(cm) {195 cm.setSize(null, 100);196 addDoc(cm, 32, 200);197 var top = cm.charCoords(Pos(0, 0));198 var bot = cm.charCoords(Pos(200, 30));199 is(top.left < bot.left);200 is(top.top < bot.top);201 is(top.top < top.bottom);202 cm.scrollTo(null, 100);203 var top2 = cm.charCoords(Pos(0, 0));204 is(top.top > top2.top);205 eq(top.left, top2.left);206});207testCM("coordsChar", function(cm) {208 addDoc(cm, 35, 70);209 for (var i = 0; i < 2; ++i) {210 var sys = i ? "local" : "page";211 for (var ch = 0; ch <= 35; ch += 5) {212 for (var line = 0; line < 70; line += 5) {213 cm.setCursor(line, ch);214 var coords = cm.charCoords(Pos(line, ch), sys);215 var pos = cm.coordsChar({left: coords.left + 1, top: coords.top + 1}, sys);216 eqPos(pos, Pos(line, ch));217 }218 }219 }220}, {lineNumbers: true});221testCM("posFromIndex", function(cm) {222 cm.setValue(223 "This function should\n" +224 "convert a zero based index\n" +225 "to line and ch."226 );227 var examples = [228 { index: -1, line: 0, ch: 0 }, // <- Tests clipping229 { index: 0, line: 0, ch: 0 },230 { index: 10, line: 0, ch: 10 },231 { index: 39, line: 1, ch: 18 },232 { index: 55, line: 2, ch: 7 },233 { index: 63, line: 2, ch: 15 },234 { index: 64, line: 2, ch: 15 } // <- Tests clipping235 ];236 for (var i = 0; i < examples.length; i++) {237 var example = examples[i];238 var pos = cm.posFromIndex(example.index);239 eq(pos.line, example.line);240 eq(pos.ch, example.ch);241 if (example.index >= 0 && example.index < 64)242 eq(cm.indexFromPos(pos), example.index);243 }244});245testCM("undo", function(cm) {246 cm.replaceRange("def", Pos(0, 0), Pos(0));247 eq(cm.historySize().undo, 1);248 cm.undo();249 eq(cm.getValue(), "abc");250 eq(cm.historySize().undo, 0);251 eq(cm.historySize().redo, 1);252 cm.redo();253 eq(cm.getValue(), "def");254 eq(cm.historySize().undo, 1);255 eq(cm.historySize().redo, 0);256 cm.setValue("1\n\n\n2");257 cm.clearHistory();258 eq(cm.historySize().undo, 0);259 for (var i = 0; i < 20; ++i) {260 cm.replaceRange("a", Pos(0, 0));261 cm.replaceRange("b", Pos(3, 0));262 }263 eq(cm.historySize().undo, 40);264 for (var i = 0; i < 40; ++i)265 cm.undo();266 eq(cm.historySize().redo, 40);267 eq(cm.getValue(), "1\n\n\n2");268}, {value: "abc"});269testCM("undoDepth", function(cm) {270 cm.replaceRange("d", Pos(0));271 cm.replaceRange("e", Pos(0));272 cm.replaceRange("f", Pos(0));273 cm.undo(); cm.undo(); cm.undo();274 eq(cm.getValue(), "abcd");275}, {value: "abc", undoDepth: 4});276testCM("undoDoesntClearValue", function(cm) {277 cm.undo();278 eq(cm.getValue(), "x");279}, {value: "x"});280testCM("undoMultiLine", function(cm) {281 cm.operation(function() {282 cm.replaceRange("x", Pos(0, 0));283 cm.replaceRange("y", Pos(1, 0));284 });285 cm.undo();286 eq(cm.getValue(), "abc\ndef\nghi");287 cm.operation(function() {288 cm.replaceRange("y", Pos(1, 0));289 cm.replaceRange("x", Pos(0, 0));290 });291 cm.undo();292 eq(cm.getValue(), "abc\ndef\nghi");293 cm.operation(function() {294 cm.replaceRange("y", Pos(2, 0));295 cm.replaceRange("x", Pos(1, 0));296 cm.replaceRange("z", Pos(2, 0));297 });298 cm.undo();299 eq(cm.getValue(), "abc\ndef\nghi", 3);300}, {value: "abc\ndef\nghi"});301testCM("undoComposite", function(cm) {302 cm.replaceRange("y", Pos(1));303 cm.operation(function() {304 cm.replaceRange("x", Pos(0));305 cm.replaceRange("z", Pos(2));306 });307 eq(cm.getValue(), "ax\nby\ncz\n");308 cm.undo();309 eq(cm.getValue(), "a\nby\nc\n");310 cm.undo();311 eq(cm.getValue(), "a\nb\nc\n");312 cm.redo(); cm.redo();313 eq(cm.getValue(), "ax\nby\ncz\n");314}, {value: "a\nb\nc\n"});315testCM("undoSelection", function(cm) {316 cm.setSelection(Pos(0, 2), Pos(0, 4));317 cm.replaceSelection("");318 cm.setCursor(Pos(1, 0));319 cm.undo();320 eqPos(cm.getCursor(true), Pos(0, 2));321 eqPos(cm.getCursor(false), Pos(0, 4));322 cm.setCursor(Pos(1, 0));323 cm.redo();324 eqPos(cm.getCursor(true), Pos(0, 2));325 eqPos(cm.getCursor(false), Pos(0, 2));326}, {value: "abcdefgh\n"});327testCM("undoSelectionAsBefore", function(cm) {328 cm.replaceSelection("abc", "around");329 cm.undo();330 cm.redo();331 eq(cm.getSelection(), "abc");332});333testCM("selectionChangeConfusesHistory", function(cm) {334 cm.replaceSelection("abc", null, "dontmerge");335 cm.operation(function() {336 cm.setCursor(Pos(0, 0));337 cm.replaceSelection("abc", null, "dontmerge");338 });339 eq(cm.historySize().undo, 2);340});341testCM("markTextSingleLine", function(cm) {342 forEach([{a: 0, b: 1, c: "", f: 2, t: 5},343 {a: 0, b: 4, c: "", f: 0, t: 2},344 {a: 1, b: 2, c: "x", f: 3, t: 6},345 {a: 4, b: 5, c: "", f: 3, t: 5},346 {a: 4, b: 5, c: "xx", f: 3, t: 7},347 {a: 2, b: 5, c: "", f: 2, t: 3},348 {a: 2, b: 5, c: "abcd", f: 6, t: 7},349 {a: 2, b: 6, c: "x", f: null, t: null},350 {a: 3, b: 6, c: "", f: null, t: null},351 {a: 0, b: 9, c: "hallo", f: null, t: null},352 {a: 4, b: 6, c: "x", f: 3, t: 4},353 {a: 4, b: 8, c: "", f: 3, t: 4},354 {a: 6, b: 6, c: "a", f: 3, t: 6},355 {a: 8, b: 9, c: "", f: 3, t: 6}], function(test) {356 cm.setValue("1234567890");357 var r = cm.markText(Pos(0, 3), Pos(0, 6), {className: "foo"});358 cm.replaceRange(test.c, Pos(0, test.a), Pos(0, test.b));359 var f = r.find();360 eq(f && f.from.ch, test.f); eq(f && f.to.ch, test.t);361 });362});363testCM("markTextMultiLine", function(cm) {364 function p(v) { return v && Pos(v[0], v[1]); }365 forEach([{a: [0, 0], b: [0, 5], c: "", f: [0, 0], t: [2, 5]},366 {a: [0, 0], b: [0, 5], c: "foo\n", f: [1, 0], t: [3, 5]},367 {a: [0, 1], b: [0, 10], c: "", f: [0, 1], t: [2, 5]},368 {a: [0, 5], b: [0, 6], c: "x", f: [0, 6], t: [2, 5]},369 {a: [0, 0], b: [1, 0], c: "", f: [0, 0], t: [1, 5]},370 {a: [0, 6], b: [2, 4], c: "", f: [0, 5], t: [0, 7]},371 {a: [0, 6], b: [2, 4], c: "aa", f: [0, 5], t: [0, 9]},372 {a: [1, 2], b: [1, 8], c: "", f: [0, 5], t: [2, 5]},373 {a: [0, 5], b: [2, 5], c: "xx", f: null, t: null},374 {a: [0, 0], b: [2, 10], c: "x", f: null, t: null},375 {a: [1, 5], b: [2, 5], c: "", f: [0, 5], t: [1, 5]},376 {a: [2, 0], b: [2, 3], c: "", f: [0, 5], t: [2, 2]},377 {a: [2, 5], b: [3, 0], c: "a\nb", f: [0, 5], t: [2, 5]},378 {a: [2, 3], b: [3, 0], c: "x", f: [0, 5], t: [2, 3]},379 {a: [1, 1], b: [1, 9], c: "1\n2\n3", f: [0, 5], t: [4, 5]}], function(test) {380 cm.setValue("aaaaaaaaaa\nbbbbbbbbbb\ncccccccccc\ndddddddd\n");381 var r = cm.markText(Pos(0, 5), Pos(2, 5),382 {className: "CodeMirror-matchingbracket"});383 cm.replaceRange(test.c, p(test.a), p(test.b));384 var f = r.find();385 eqPos(f && f.from, p(test.f)); eqPos(f && f.to, p(test.t));386 });387});388testCM("markTextUndo", function(cm) {389 var marker1, marker2, bookmark;390 marker1 = cm.markText(Pos(0, 1), Pos(0, 3),391 {className: "CodeMirror-matchingbracket"});392 marker2 = cm.markText(Pos(0, 0), Pos(2, 1),393 {className: "CodeMirror-matchingbracket"});394 bookmark = cm.setBookmark(Pos(1, 5));395 cm.operation(function(){396 cm.replaceRange("foo", Pos(0, 2));397 cm.replaceRange("bar\nbaz\nbug\n", Pos(2, 0), Pos(3, 0));398 });399 var v1 = cm.getValue();400 cm.setValue("");401 eq(marker1.find(), null); eq(marker2.find(), null); eq(bookmark.find(), null);402 cm.undo();403 eqPos(bookmark.find(), Pos(1, 5), "still there");404 cm.undo();405 var m1Pos = marker1.find(), m2Pos = marker2.find();406 eqPos(m1Pos.from, Pos(0, 1)); eqPos(m1Pos.to, Pos(0, 3));407 eqPos(m2Pos.from, Pos(0, 0)); eqPos(m2Pos.to, Pos(2, 1));408 eqPos(bookmark.find(), Pos(1, 5));409 cm.redo(); cm.redo();410 eq(bookmark.find(), null);411 cm.undo();412 eqPos(bookmark.find(), Pos(1, 5));413 eq(cm.getValue(), v1);414}, {value: "1234\n56789\n00\n"});415testCM("markTextStayGone", function(cm) {416 var m1 = cm.markText(Pos(0, 0), Pos(0, 1));417 cm.replaceRange("hi", Pos(0, 2));418 m1.clear();419 cm.undo();420 eq(m1.find(), null);421}, {value: "hello"});422testCM("markTextAllowEmpty", function(cm) {423 var m1 = cm.markText(Pos(0, 1), Pos(0, 2), {clearWhenEmpty: false});424 is(m1.find());425 cm.replaceRange("x", Pos(0, 0));426 is(m1.find());427 cm.replaceRange("y", Pos(0, 2));428 is(m1.find());429 cm.replaceRange("z", Pos(0, 3), Pos(0, 4));430 is(!m1.find());431 var m2 = cm.markText(Pos(0, 1), Pos(0, 2), {clearWhenEmpty: false,432 inclusiveLeft: true,433 inclusiveRight: true});434 cm.replaceRange("q", Pos(0, 1), Pos(0, 2));435 is(m2.find());436 cm.replaceRange("", Pos(0, 0), Pos(0, 3));437 is(!m2.find());438 var m3 = cm.markText(Pos(0, 1), Pos(0, 1), {clearWhenEmpty: false});439 cm.replaceRange("a", Pos(0, 3));440 is(m3.find());441 cm.replaceRange("b", Pos(0, 1));442 is(!m3.find());443}, {value: "abcde"});444testCM("markTextStacked", function(cm) {445 var m1 = cm.markText(Pos(0, 0), Pos(0, 0), {clearWhenEmpty: false});446 var m2 = cm.markText(Pos(0, 0), Pos(0, 0), {clearWhenEmpty: false});447 cm.replaceRange("B", Pos(0, 1));448 is(m1.find() && m2.find());449}, {value: "A"});450testCM("undoPreservesNewMarks", function(cm) {451 cm.markText(Pos(0, 3), Pos(0, 4));452 cm.markText(Pos(1, 1), Pos(1, 3));453 cm.replaceRange("", Pos(0, 3), Pos(3, 1));454 var mBefore = cm.markText(Pos(0, 0), Pos(0, 1));455 var mAfter = cm.markText(Pos(0, 5), Pos(0, 6));456 var mAround = cm.markText(Pos(0, 2), Pos(0, 4));457 cm.undo();458 eqPos(mBefore.find().from, Pos(0, 0));459 eqPos(mBefore.find().to, Pos(0, 1));460 eqPos(mAfter.find().from, Pos(3, 3));461 eqPos(mAfter.find().to, Pos(3, 4));462 eqPos(mAround.find().from, Pos(0, 2));463 eqPos(mAround.find().to, Pos(3, 2));464 var found = cm.findMarksAt(Pos(2, 2));465 eq(found.length, 1);466 eq(found[0], mAround);467}, {value: "aaaa\nbbbb\ncccc\ndddd"});468testCM("markClearBetween", function(cm) {469 cm.setValue("aaa\nbbb\nccc\nddd\n");470 cm.markText(Pos(0, 0), Pos(2));471 cm.replaceRange("aaa\nbbb\nccc", Pos(0, 0), Pos(2));472 eq(cm.findMarksAt(Pos(1, 1)).length, 0);473});474testCM("deleteSpanCollapsedInclusiveLeft", function(cm) {475 var from = Pos(1, 0), to = Pos(1, 1);476 var m = cm.markText(from, to, {collapsed: true, inclusiveLeft: true});477 // Delete collapsed span.478 cm.replaceRange("", from, to);479}, {value: "abc\nX\ndef"});480testCM("bookmark", function(cm) {481 function p(v) { return v && Pos(v[0], v[1]); }482 forEach([{a: [1, 0], b: [1, 1], c: "", d: [1, 4]},483 {a: [1, 1], b: [1, 1], c: "xx", d: [1, 7]},484 {a: [1, 4], b: [1, 5], c: "ab", d: [1, 6]},485 {a: [1, 4], b: [1, 6], c: "", d: null},486 {a: [1, 5], b: [1, 6], c: "abc", d: [1, 5]},487 {a: [1, 6], b: [1, 8], c: "", d: [1, 5]},488 {a: [1, 4], b: [1, 4], c: "\n\n", d: [3, 1]},489 {bm: [1, 9], a: [1, 1], b: [1, 1], c: "\n", d: [2, 8]}], function(test) {490 cm.setValue("1234567890\n1234567890\n1234567890");491 var b = cm.setBookmark(p(test.bm) || Pos(1, 5));492 cm.replaceRange(test.c, p(test.a), p(test.b));493 eqPos(b.find(), p(test.d));494 });495});496testCM("bookmarkInsertLeft", function(cm) {497 var br = cm.setBookmark(Pos(0, 2), {insertLeft: false});498 var bl = cm.setBookmark(Pos(0, 2), {insertLeft: true});499 cm.setCursor(Pos(0, 2));500 cm.replaceSelection("hi");501 eqPos(br.find(), Pos(0, 2));502 eqPos(bl.find(), Pos(0, 4));503 cm.replaceRange("", Pos(0, 4), Pos(0, 5));504 cm.replaceRange("", Pos(0, 2), Pos(0, 4));505 cm.replaceRange("", Pos(0, 1), Pos(0, 2));506 // Verify that deleting next to bookmarks doesn't kill them507 eqPos(br.find(), Pos(0, 1));508 eqPos(bl.find(), Pos(0, 1));509}, {value: "abcdef"});510testCM("bookmarkCursor", function(cm) {511 var pos01 = cm.cursorCoords(Pos(0, 1)), pos11 = cm.cursorCoords(Pos(1, 1)),512 pos20 = cm.cursorCoords(Pos(2, 0)), pos30 = cm.cursorCoords(Pos(3, 0)),513 pos41 = cm.cursorCoords(Pos(4, 1));514 cm.setBookmark(Pos(0, 1), {widget: document.createTextNode("←"), insertLeft: true});515 cm.setBookmark(Pos(2, 0), {widget: document.createTextNode("←"), insertLeft: true});516 cm.setBookmark(Pos(1, 1), {widget: document.createTextNode("→")});517 cm.setBookmark(Pos(3, 0), {widget: document.createTextNode("→")});518 var new01 = cm.cursorCoords(Pos(0, 1)), new11 = cm.cursorCoords(Pos(1, 1)),519 new20 = cm.cursorCoords(Pos(2, 0)), new30 = cm.cursorCoords(Pos(3, 0));520 near(new01.left, pos01.left, 1);521 near(new01.top, pos01.top, 1);522 is(new11.left > pos11.left, "at right, middle of line");523 near(new11.top == pos11.top, 1);524 near(new20.left, pos20.left, 1);525 near(new20.top, pos20.top, 1);526 is(new30.left > pos30.left, "at right, empty line");527 near(new30.top, pos30, 1);528 cm.setBookmark(Pos(4, 0), {widget: document.createTextNode("→")});529 is(cm.cursorCoords(Pos(4, 1)).left > pos41.left, "single-char bug");530}, {value: "foo\nbar\n\n\nx\ny"});531testCM("multiBookmarkCursor", function(cm) {532 if (phantom) return;533 var ms = [], m;534 function add(insertLeft) {535 for (var i = 0; i < 3; ++i) {536 var node = document.createElement("span");537 node.innerHTML = "X";538 ms.push(cm.setBookmark(Pos(0, 1), {widget: node, insertLeft: insertLeft}));539 }540 }541 var base1 = cm.cursorCoords(Pos(0, 1)).left, base4 = cm.cursorCoords(Pos(0, 4)).left;542 add(true);543 near(base1, cm.cursorCoords(Pos(0, 1)).left, 1);544 while (m = ms.pop()) m.clear();545 add(false);546 near(base4, cm.cursorCoords(Pos(0, 1)).left, 1);547}, {value: "abcdefg"});548testCM("getAllMarks", function(cm) {549 addDoc(cm, 10, 10);550 var m1 = cm.setBookmark(Pos(0, 2));551 var m2 = cm.markText(Pos(0, 2), Pos(3, 2));552 var m3 = cm.markText(Pos(1, 2), Pos(1, 8));553 var m4 = cm.markText(Pos(8, 0), Pos(9, 0));554 eq(cm.getAllMarks().length, 4);555 m1.clear();556 m3.clear();557 eq(cm.getAllMarks().length, 2);558});559testCM("bug577", function(cm) {560 cm.setValue("a\nb");561 cm.clearHistory();562 cm.setValue("fooooo");563 cm.undo();564});565testCM("scrollSnap", function(cm) {566 cm.setSize(100, 100);567 addDoc(cm, 200, 200);568 cm.setCursor(Pos(100, 180));569 var info = cm.getScrollInfo();570 is(info.left > 0 && info.top > 0);571 cm.setCursor(Pos(0, 0));572 info = cm.getScrollInfo();573 is(info.left == 0 && info.top == 0, "scrolled clean to top");574 cm.setCursor(Pos(100, 180));575 cm.setCursor(Pos(199, 0));576 info = cm.getScrollInfo();577 is(info.left == 0 && info.top + 2 > info.height - cm.getScrollerElement().clientHeight, "scrolled clean to bottom");578});579testCM("scrollIntoView", function(cm) {580 if (phantom) return;581 var outer = cm.getWrapperElement().getBoundingClientRect();582 function test(line, ch, msg) {583 var pos = Pos(line, ch);584 cm.scrollIntoView(pos);585 var box = cm.charCoords(pos, "window");586 is(box.left >= outer.left, msg + " (left)");587 is(box.right <= outer.right, msg + " (right)");588 is(box.top >= outer.top, msg + " (top)");589 is(box.bottom <= outer.bottom, msg + " (bottom)");590 }591 addDoc(cm, 200, 200);592 test(199, 199, "bottom right");593 test(0, 0, "top left");594 test(100, 100, "center");595 test(199, 0, "bottom left");596 test(0, 199, "top right");597 test(100, 100, "center again");598});599testCM("scrollBackAndForth", function(cm) {600 addDoc(cm, 1, 200);601 cm.operation(function() {602 cm.scrollIntoView(Pos(199, 0));603 cm.scrollIntoView(Pos(4, 0));604 });605 is(cm.getScrollInfo().top > 0);606});607testCM("selectAllNoScroll", function(cm) {608 addDoc(cm, 1, 200);609 cm.execCommand("selectAll");610 eq(cm.getScrollInfo().top, 0);611 cm.setCursor(199);612 cm.execCommand("selectAll");613 is(cm.getScrollInfo().top > 0);614});615testCM("selectionPos", function(cm) {616 if (phantom) return;617 cm.setSize(100, 100);618 addDoc(cm, 200, 100);619 cm.setSelection(Pos(1, 100), Pos(98, 100));620 var lineWidth = cm.charCoords(Pos(0, 200), "local").left;621 var lineHeight = (cm.charCoords(Pos(99)).top - cm.charCoords(Pos(0)).top) / 100;622 cm.scrollTo(0, 0);623 var selElt = byClassName(cm.getWrapperElement(), "CodeMirror-selected");624 var outer = cm.getWrapperElement().getBoundingClientRect();625 var sawMiddle, sawTop, sawBottom;626 for (var i = 0, e = selElt.length; i < e; ++i) {627 var box = selElt[i].getBoundingClientRect();628 var atLeft = box.left - outer.left < 30;629 var width = box.right - box.left;630 var atRight = box.right - outer.left > .8 * lineWidth;631 if (atLeft && atRight) {632 sawMiddle = true;633 is(box.bottom - box.top > 90 * lineHeight, "middle high");634 is(width > .9 * lineWidth, "middle wide");635 } else {636 is(width > .4 * lineWidth, "top/bot wide enough");637 is(width < .6 * lineWidth, "top/bot slim enough");638 if (atLeft) {639 sawBottom = true;640 is(box.top - outer.top > 96 * lineHeight, "bot below");641 } else if (atRight) {642 sawTop = true;643 is(box.top - outer.top < 2.1 * lineHeight, "top above");644 }645 }646 }647 is(sawTop && sawBottom && sawMiddle, "all parts");648}, null);649testCM("restoreHistory", function(cm) {650 cm.setValue("abc\ndef");651 cm.replaceRange("hello", Pos(1, 0), Pos(1));652 cm.replaceRange("goop", Pos(0, 0), Pos(0));653 cm.undo();654 var storedVal = cm.getValue(), storedHist = cm.getHistory();655 if (window.JSON) storedHist = JSON.parse(JSON.stringify(storedHist));656 eq(storedVal, "abc\nhello");657 cm.setValue("");658 cm.clearHistory();659 eq(cm.historySize().undo, 0);660 cm.setValue(storedVal);661 cm.setHistory(storedHist);662 cm.redo();663 eq(cm.getValue(), "goop\nhello");664 cm.undo(); cm.undo();665 eq(cm.getValue(), "abc\ndef");666});667testCM("doubleScrollbar", function(cm) {668 var dummy = document.body.appendChild(document.createElement("p"));669 dummy.style.cssText = "height: 50px; overflow: scroll; width: 50px";670 var scrollbarWidth = dummy.offsetWidth + 1 - dummy.clientWidth;671 document.body.removeChild(dummy);672 if (scrollbarWidth < 2) return;673 cm.setSize(null, 100);674 addDoc(cm, 1, 300);675 var wrap = cm.getWrapperElement();676 is(wrap.offsetWidth - byClassName(wrap, "CodeMirror-lines")[0].offsetWidth <= scrollbarWidth * 1.5);677});678testCM("weirdLinebreaks", function(cm) {679 cm.setValue("foo\nbar\rbaz\r\nquux\n\rplop");680 is(cm.getValue(), "foo\nbar\nbaz\nquux\n\nplop");681 is(cm.lineCount(), 6);682 cm.setValue("\n\n");683 is(cm.lineCount(), 3);684});685testCM("setSize", function(cm) {686 cm.setSize(100, 100);687 var wrap = cm.getWrapperElement();688 is(wrap.offsetWidth, 100);689 is(wrap.offsetHeight, 100);690 cm.setSize("100%", "3em");691 is(wrap.style.width, "100%");692 is(wrap.style.height, "3em");693 cm.setSize(null, 40);694 is(wrap.style.width, "100%");695 is(wrap.style.height, "40px");696});697function foldLines(cm, start, end, autoClear) {698 return cm.markText(Pos(start, 0), Pos(end - 1), {699 inclusiveLeft: true,700 inclusiveRight: true,701 collapsed: true,702 clearOnEnter: autoClear703 });704}705testCM("collapsedLines", function(cm) {706 addDoc(cm, 4, 10);707 var range = foldLines(cm, 4, 5), cleared = 0;708 CodeMirror.on(range, "clear", function() {cleared++;});709 cm.setCursor(Pos(3, 0));710 CodeMirror.commands.goLineDown(cm);711 eqPos(cm.getCursor(), Pos(5, 0));712 cm.replaceRange("abcdefg", Pos(3, 0), Pos(3));713 cm.setCursor(Pos(3, 6));714 CodeMirror.commands.goLineDown(cm);715 eqPos(cm.getCursor(), Pos(5, 4));716 cm.replaceRange("ab", Pos(3, 0), Pos(3));717 cm.setCursor(Pos(3, 2));718 CodeMirror.commands.goLineDown(cm);719 eqPos(cm.getCursor(), Pos(5, 2));720 cm.operation(function() {range.clear(); range.clear();});721 eq(cleared, 1);722});723testCM("collapsedRangeCoordsChar", function(cm) {724 var pos_1_3 = cm.charCoords(Pos(1, 3));725 pos_1_3.left += 2; pos_1_3.top += 2;726 var opts = {collapsed: true, inclusiveLeft: true, inclusiveRight: true};727 var m1 = cm.markText(Pos(0, 0), Pos(2, 0), opts);728 eqPos(cm.coordsChar(pos_1_3), Pos(3, 3));729 m1.clear();730 var m1 = cm.markText(Pos(0, 0), Pos(1, 1), {collapsed: true, inclusiveLeft: true});731 var m2 = cm.markText(Pos(1, 1), Pos(2, 0), {collapsed: true, inclusiveRight: true});732 eqPos(cm.coordsChar(pos_1_3), Pos(3, 3));733 m1.clear(); m2.clear();734 var m1 = cm.markText(Pos(0, 0), Pos(1, 6), opts);735 eqPos(cm.coordsChar(pos_1_3), Pos(3, 3));736}, {value: "123456\nabcdef\nghijkl\nmnopqr\n"});737testCM("collapsedRangeBetweenLinesSelected", function(cm) {738 var widget = document.createElement("span");739 widget.textContent = "\u2194";740 cm.markText(Pos(0, 3), Pos(1, 0), {replacedWith: widget});741 cm.setSelection(Pos(0, 3), Pos(1, 0));742 var selElts = byClassName(cm.getWrapperElement(), "CodeMirror-selected");743 for (var i = 0, w = 0; i < selElts.length; i++)744 w += selElts[i].offsetWidth;745 is(w > 0);746}, {value: "one\ntwo"});747testCM("randomCollapsedRanges", function(cm) {748 addDoc(cm, 20, 500);749 cm.operation(function() {750 for (var i = 0; i < 200; i++) {751 var start = Pos(Math.floor(Math.random() * 500), Math.floor(Math.random() * 20));752 if (i % 4)753 try { cm.markText(start, Pos(start.line + 2, 1), {collapsed: true}); }754 catch(e) { if (!/overlapping/.test(String(e))) throw e; }755 else756 cm.markText(start, Pos(start.line, start.ch + 4), {"className": "foo"});757 }758 });759});760testCM("hiddenLinesAutoUnfold", function(cm) {761 var range = foldLines(cm, 1, 3, true), cleared = 0;762 CodeMirror.on(range, "clear", function() {cleared++;});763 cm.setCursor(Pos(3, 0));764 eq(cleared, 0);765 cm.execCommand("goCharLeft");766 eq(cleared, 1);767 range = foldLines(cm, 1, 3, true);768 CodeMirror.on(range, "clear", function() {cleared++;});769 eqPos(cm.getCursor(), Pos(3, 0));770 cm.setCursor(Pos(0, 3));771 cm.execCommand("goCharRight");772 eq(cleared, 2);773}, {value: "abc\ndef\nghi\njkl"});774testCM("hiddenLinesSelectAll", function(cm) { // Issue #484775 addDoc(cm, 4, 20);776 foldLines(cm, 0, 10);777 foldLines(cm, 11, 20);778 CodeMirror.commands.selectAll(cm);779 eqPos(cm.getCursor(true), Pos(10, 0));780 eqPos(cm.getCursor(false), Pos(10, 4));781});782testCM("everythingFolded", function(cm) {783 addDoc(cm, 2, 2);784 function enterPress() {785 cm.triggerOnKeyDown({type: "keydown", keyCode: 13, preventDefault: function(){}, stopPropagation: function(){}});786 }787 var fold = foldLines(cm, 0, 2);788 enterPress();789 eq(cm.getValue(), "xx\nxx");790 fold.clear();791 fold = foldLines(cm, 0, 2, true);792 eq(fold.find(), null);793 enterPress();794 eq(cm.getValue(), "\nxx\nxx");795});796testCM("structuredFold", function(cm) {797 if (phantom) return;798 addDoc(cm, 4, 8);799 var range = cm.markText(Pos(1, 2), Pos(6, 2), {800 replacedWith: document.createTextNode("Q")801 });802 cm.setCursor(0, 3);803 CodeMirror.commands.goLineDown(cm);804 eqPos(cm.getCursor(), Pos(6, 2));805 CodeMirror.commands.goCharLeft(cm);806 eqPos(cm.getCursor(), Pos(1, 2));807 CodeMirror.commands.delCharAfter(cm);808 eq(cm.getValue(), "xxxx\nxxxx\nxxxx");809 addDoc(cm, 4, 8);810 range = cm.markText(Pos(1, 2), Pos(6, 2), {811 replacedWith: document.createTextNode("M"),812 clearOnEnter: true813 });814 var cleared = 0;815 CodeMirror.on(range, "clear", function(){++cleared;});816 cm.setCursor(0, 3);817 CodeMirror.commands.goLineDown(cm);818 eqPos(cm.getCursor(), Pos(6, 2));819 CodeMirror.commands.goCharLeft(cm);820 eqPos(cm.getCursor(), Pos(6, 1));821 eq(cleared, 1);822 range.clear();823 eq(cleared, 1);824 range = cm.markText(Pos(1, 2), Pos(6, 2), {825 replacedWith: document.createTextNode("Q"),826 clearOnEnter: true827 });828 range.clear();829 cm.setCursor(1, 2);830 CodeMirror.commands.goCharRight(cm);831 eqPos(cm.getCursor(), Pos(1, 3));832 range = cm.markText(Pos(2, 0), Pos(4, 4), {833 replacedWith: document.createTextNode("M")834 });835 cm.setCursor(1, 0);836 CodeMirror.commands.goLineDown(cm);837 eqPos(cm.getCursor(), Pos(2, 0));838}, null);839testCM("nestedFold", function(cm) {840 addDoc(cm, 10, 3);841 function fold(ll, cl, lr, cr) {842 return cm.markText(Pos(ll, cl), Pos(lr, cr), {collapsed: true});843 }844 var inner1 = fold(0, 6, 1, 3), inner2 = fold(0, 2, 1, 8), outer = fold(0, 1, 2, 3), inner0 = fold(0, 5, 0, 6);845 cm.setCursor(0, 1);846 CodeMirror.commands.goCharRight(cm);847 eqPos(cm.getCursor(), Pos(2, 3));848 inner0.clear();849 CodeMirror.commands.goCharLeft(cm);850 eqPos(cm.getCursor(), Pos(0, 1));851 outer.clear();852 CodeMirror.commands.goCharRight(cm);853 eqPos(cm.getCursor(), Pos(0, 2));854 CodeMirror.commands.goCharRight(cm);855 eqPos(cm.getCursor(), Pos(1, 8));856 inner2.clear();857 CodeMirror.commands.goCharLeft(cm);858 eqPos(cm.getCursor(), Pos(1, 7));859 cm.setCursor(0, 5);860 CodeMirror.commands.goCharRight(cm);861 eqPos(cm.getCursor(), Pos(0, 6));862 CodeMirror.commands.goCharRight(cm);863 eqPos(cm.getCursor(), Pos(1, 3));864});865testCM("badNestedFold", function(cm) {866 addDoc(cm, 4, 4);867 cm.markText(Pos(0, 2), Pos(3, 2), {collapsed: true});868 var caught;869 try {cm.markText(Pos(0, 1), Pos(0, 3), {collapsed: true});}870 catch(e) {caught = e;}871 is(caught instanceof Error, "no error");872 is(/overlap/i.test(caught.message), "wrong error");873});874testCM("nestedFoldOnSide", function(cm) {875 var m1 = cm.markText(Pos(0, 1), Pos(2, 1), {collapsed: true, inclusiveRight: true});876 var m2 = cm.markText(Pos(0, 1), Pos(0, 2), {collapsed: true});877 cm.markText(Pos(0, 1), Pos(0, 2), {collapsed: true}).clear();878 try { cm.markText(Pos(0, 1), Pos(0, 2), {collapsed: true, inclusiveLeft: true}); }879 catch(e) { var caught = e; }880 is(caught && /overlap/i.test(caught.message));881 var m3 = cm.markText(Pos(2, 0), Pos(2, 1), {collapsed: true});882 var m4 = cm.markText(Pos(2, 0), Pos(2, 1), {collapse: true, inclusiveRight: true});883 m1.clear(); m4.clear();884 m1 = cm.markText(Pos(0, 1), Pos(2, 1), {collapsed: true});885 cm.markText(Pos(2, 0), Pos(2, 1), {collapsed: true}).clear();886 try { cm.markText(Pos(2, 0), Pos(2, 1), {collapsed: true, inclusiveRight: true}); }887 catch(e) { var caught = e; }888 is(caught && /overlap/i.test(caught.message));889}, {value: "ab\ncd\ef"});890testCM("editInFold", function(cm) {891 addDoc(cm, 4, 6);892 var m = cm.markText(Pos(1, 2), Pos(3, 2), {collapsed: true});893 cm.replaceRange("", Pos(0, 0), Pos(1, 3));894 cm.replaceRange("", Pos(2, 1), Pos(3, 3));895 cm.replaceRange("a\nb\nc\nd", Pos(0, 1), Pos(1, 0));896 cm.cursorCoords(Pos(0, 0));897});898testCM("wrappingInlineWidget", function(cm) {899 cm.setSize("11em");900 var w = document.createElement("span");901 w.style.color = "red";902 w.innerHTML = "one two three four";903 cm.markText(Pos(0, 6), Pos(0, 9), {replacedWith: w});904 var cur0 = cm.cursorCoords(Pos(0, 0)), cur1 = cm.cursorCoords(Pos(0, 10));905 is(cur0.top < cur1.top);906 is(cur0.bottom < cur1.bottom);907 var curL = cm.cursorCoords(Pos(0, 6)), curR = cm.cursorCoords(Pos(0, 9));908 eq(curL.top, cur0.top);909 eq(curL.bottom, cur0.bottom);910 eq(curR.top, cur1.top);911 eq(curR.bottom, cur1.bottom);912 cm.replaceRange("", Pos(0, 9), Pos(0));913 curR = cm.cursorCoords(Pos(0, 9));914 if (phantom) return;915 eq(curR.top, cur1.top);916 eq(curR.bottom, cur1.bottom);917}, {value: "1 2 3 xxx 4", lineWrapping: true});918testCM("changedInlineWidget", function(cm) {919 cm.setSize("10em");920 var w = document.createElement("span");921 w.innerHTML = "x";922 var m = cm.markText(Pos(0, 4), Pos(0, 5), {replacedWith: w});923 w.innerHTML = "and now the widget is really really long all of a sudden and a scrollbar is needed";924 m.changed();925 var hScroll = byClassName(cm.getWrapperElement(), "CodeMirror-hscrollbar")[0];926 is(hScroll.scrollWidth > hScroll.clientWidth);927}, {value: "hello there"});928testCM("changedBookmark", function(cm) {929 cm.setSize("10em");930 var w = document.createElement("span");931 w.innerHTML = "x";932 var m = cm.setBookmark(Pos(0, 4), {widget: w});933 w.innerHTML = "and now the widget is really really long all of a sudden and a scrollbar is needed";934 m.changed();935 var hScroll = byClassName(cm.getWrapperElement(), "CodeMirror-hscrollbar")[0];936 is(hScroll.scrollWidth > hScroll.clientWidth);937}, {value: "abcdefg"});938testCM("inlineWidget", function(cm) {939 var w = cm.setBookmark(Pos(0, 2), {widget: document.createTextNode("uu")});940 cm.setCursor(0, 2);941 CodeMirror.commands.goLineDown(cm);942 eqPos(cm.getCursor(), Pos(1, 4));943 cm.setCursor(0, 2);944 cm.replaceSelection("hi");945 eqPos(w.find(), Pos(0, 2));946 cm.setCursor(0, 1);947 cm.replaceSelection("ay");948 eqPos(w.find(), Pos(0, 4));949 eq(cm.getLine(0), "uayuhiuu");950}, {value: "uuuu\nuuuuuu"});951testCM("wrappingAndResizing", function(cm) {952 cm.setSize(null, "auto");953 cm.setOption("lineWrapping", true);954 var wrap = cm.getWrapperElement(), h0 = wrap.offsetHeight;955 var doc = "xxx xxx xxx xxx xxx";956 cm.setValue(doc);957 for (var step = 10, w = cm.charCoords(Pos(0, 18), "div").right;; w += step) {958 cm.setSize(w);959 if (wrap.offsetHeight <= h0 * (opera_lt10 ? 1.2 : 1.5)) {960 if (step == 10) { w -= 10; step = 1; }961 else break;962 }963 }964 // Ensure that putting the cursor at the end of the maximally long965 // line doesn't cause wrapping to happen.966 cm.setCursor(Pos(0, doc.length));967 eq(wrap.offsetHeight, h0);968 cm.replaceSelection("x");969 is(wrap.offsetHeight > h0, "wrapping happens");970 // Now add a max-height and, in a document consisting of971 // almost-wrapped lines, go over it so that a scrollbar appears.972 cm.setValue(doc + "\n" + doc + "\n");973 cm.getScrollerElement().style.maxHeight = "100px";974 cm.replaceRange("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n!\n", Pos(2, 0));975 forEach([Pos(0, doc.length), Pos(0, doc.length - 1),976 Pos(0, 0), Pos(1, doc.length), Pos(1, doc.length - 1)],977 function(pos) {978 var coords = cm.charCoords(pos);979 eqPos(pos, cm.coordsChar({left: coords.left + 2, top: coords.top + 5}));980 });981}, null, ie_lt8);982testCM("measureEndOfLine", function(cm) {983 cm.setSize(null, "auto");984 var inner = byClassName(cm.getWrapperElement(), "CodeMirror-lines")[0].firstChild;985 var lh = inner.offsetHeight;986 for (var step = 10, w = cm.charCoords(Pos(0, 7), "div").right;; w += step) {987 cm.setSize(w);988 if (inner.offsetHeight < 2.5 * lh) {989 if (step == 10) { w -= 10; step = 1; }990 else break;991 }992 }993 cm.setValue(cm.getValue() + "\n\n");994 var endPos = cm.charCoords(Pos(0, 18), "local");995 is(endPos.top > lh * .8, "not at top");996 is(endPos.left > w - 20, "not at right");997 endPos = cm.charCoords(Pos(0, 18));998 eqPos(cm.coordsChar({left: endPos.left, top: endPos.top + 5}), Pos(0, 18));999}, {mode: "text/html", value: "<!-- foo barrr -->", lineWrapping: true}, ie_lt8 || opera_lt10);1000testCM("scrollVerticallyAndHorizontally", function(cm) {1001 cm.setSize(100, 100);1002 addDoc(cm, 40, 40);1003 cm.setCursor(39);1004 var wrap = cm.getWrapperElement(), bar = byClassName(wrap, "CodeMirror-vscrollbar")[0];1005 is(bar.offsetHeight < wrap.offsetHeight, "vertical scrollbar limited by horizontal one");1006 var cursorBox = byClassName(wrap, "CodeMirror-cursor")[0].getBoundingClientRect();1007 var editorBox = wrap.getBoundingClientRect();1008 is(cursorBox.bottom < editorBox.top + cm.getScrollerElement().clientHeight,1009 "bottom line visible");1010}, {lineNumbers: true});1011testCM("moveVstuck", function(cm) {1012 var lines = byClassName(cm.getWrapperElement(), "CodeMirror-lines")[0].firstChild, h0 = lines.offsetHeight;1013 var val = "fooooooooooooooooooooooooo baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar\n";1014 cm.setValue(val);1015 for (var w = cm.charCoords(Pos(0, 26), "div").right * 2.8;; w += 5) {1016 cm.setSize(w);1017 if (lines.offsetHeight <= 3.5 * h0) break;1018 }1019 cm.setCursor(Pos(0, val.length - 1));1020 cm.moveV(-1, "line");1021 eqPos(cm.getCursor(), Pos(0, 26));1022}, {lineWrapping: true}, ie_lt8 || opera_lt10);1023testCM("collapseOnMove", function(cm) {1024 cm.setSelection(Pos(0, 1), Pos(2, 4));1025 cm.execCommand("goLineUp");1026 is(!cm.somethingSelected());1027 eqPos(cm.getCursor(), Pos(0, 1));1028 cm.setSelection(Pos(0, 1), Pos(2, 4));1029 cm.execCommand("goPageDown");1030 is(!cm.somethingSelected());1031 eqPos(cm.getCursor(), Pos(2, 4));1032 cm.execCommand("goLineUp");1033 cm.execCommand("goLineUp");1034 eqPos(cm.getCursor(), Pos(0, 4));1035 cm.setSelection(Pos(0, 1), Pos(2, 4));1036 cm.execCommand("goCharLeft");1037 is(!cm.somethingSelected());1038 eqPos(cm.getCursor(), Pos(0, 1));1039}, {value: "aaaaa\nb\nccccc"});1040testCM("clickTab", function(cm) {1041 var p0 = cm.charCoords(Pos(0, 0));1042 eqPos(cm.coordsChar({left: p0.left + 5, top: p0.top + 5}), Pos(0, 0));1043 eqPos(cm.coordsChar({left: p0.right - 5, top: p0.top + 5}), Pos(0, 1));1044}, {value: "\t\n\n", lineWrapping: true, tabSize: 8});1045testCM("verticalScroll", function(cm) {1046 cm.setSize(100, 200);1047 cm.setValue("foo\nbar\nbaz\n");1048 var sc = cm.getScrollerElement(), baseWidth = sc.scrollWidth;1049 cm.replaceRange("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah", Pos(0, 0), Pos(0));1050 is(sc.scrollWidth > baseWidth, "scrollbar present");1051 cm.replaceRange("foo", Pos(0, 0), Pos(0));1052 if (!phantom) eq(sc.scrollWidth, baseWidth, "scrollbar gone");1053 cm.replaceRange("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah", Pos(0, 0), Pos(0));1054 cm.replaceRange("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbh", Pos(1, 0), Pos(1));1055 is(sc.scrollWidth > baseWidth, "present again");1056 var curWidth = sc.scrollWidth;1057 cm.replaceRange("foo", Pos(0, 0), Pos(0));1058 is(sc.scrollWidth < curWidth, "scrollbar smaller");1059 is(sc.scrollWidth > baseWidth, "but still present");1060});1061testCM("extraKeys", function(cm) {1062 var outcome;1063 function fakeKey(expected, code, props) {1064 if (typeof code == "string") code = code.charCodeAt(0);1065 var e = {type: "keydown", keyCode: code, preventDefault: function(){}, stopPropagation: function(){}};1066 if (props) for (var n in props) e[n] = props[n];1067 outcome = null;1068 cm.triggerOnKeyDown(e);1069 eq(outcome, expected);1070 }1071 CodeMirror.commands.testCommand = function() {outcome = "tc";};1072 CodeMirror.commands.goTestCommand = function() {outcome = "gtc";};1073 cm.setOption("extraKeys", {"Shift-X": function() {outcome = "sx";},1074 "X": function() {outcome = "x";},1075 "Ctrl-Alt-U": function() {outcome = "cau";},1076 "End": "testCommand",1077 "Home": "goTestCommand",1078 "Tab": false});1079 fakeKey(null, "U");1080 fakeKey("cau", "U", {ctrlKey: true, altKey: true});1081 fakeKey(null, "U", {shiftKey: true, ctrlKey: true, altKey: true});1082 fakeKey("x", "X");1083 fakeKey("sx", "X", {shiftKey: true});1084 fakeKey("tc", 35);1085 fakeKey(null, 35, {shiftKey: true});1086 fakeKey("gtc", 36);1087 fakeKey("gtc", 36, {shiftKey: true});1088 fakeKey(null, 9);1089}, null, window.opera && mac);1090testCM("wordMovementCommands", function(cm) {1091 cm.execCommand("goWordLeft");1092 eqPos(cm.getCursor(), Pos(0, 0));1093 cm.execCommand("goWordRight"); cm.execCommand("goWordRight");1094 eqPos(cm.getCursor(), Pos(0, 7));1095 cm.execCommand("goWordLeft");1096 eqPos(cm.getCursor(), Pos(0, 5));1097 cm.execCommand("goWordRight"); cm.execCommand("goWordRight");1098 eqPos(cm.getCursor(), Pos(0, 12));1099 cm.execCommand("goWordLeft");1100 eqPos(cm.getCursor(), Pos(0, 9));1101 cm.execCommand("goWordRight"); cm.execCommand("goWordRight"); cm.execCommand("goWordRight");1102 eqPos(cm.getCursor(), Pos(0, 24));1103 cm.execCommand("goWordRight"); cm.execCommand("goWordRight");1104 eqPos(cm.getCursor(), Pos(1, 9));1105 cm.execCommand("goWordRight");1106 eqPos(cm.getCursor(), Pos(1, 13));1107 cm.execCommand("goWordRight"); cm.execCommand("goWordRight");1108 eqPos(cm.getCursor(), Pos(2, 0));1109}, {value: "this is (the) firstline.\na foo12\u00e9\u00f8\u00d7bar\n"});1110testCM("groupMovementCommands", function(cm) {1111 cm.execCommand("goGroupLeft");1112 eqPos(cm.getCursor(), Pos(0, 0));1113 cm.execCommand("goGroupRight");1114 eqPos(cm.getCursor(), Pos(0, 4));1115 cm.execCommand("goGroupRight");1116 eqPos(cm.getCursor(), Pos(0, 7));1117 cm.execCommand("goGroupRight");1118 eqPos(cm.getCursor(), Pos(0, 10));1119 cm.execCommand("goGroupLeft");1120 eqPos(cm.getCursor(), Pos(0, 7));1121 cm.execCommand("goGroupRight"); cm.execCommand("goGroupRight"); cm.execCommand("goGroupRight");1122 eqPos(cm.getCursor(), Pos(0, 15));1123 cm.setCursor(Pos(0, 17));1124 cm.execCommand("goGroupLeft");1125 eqPos(cm.getCursor(), Pos(0, 16));1126 cm.execCommand("goGroupLeft");1127 eqPos(cm.getCursor(), Pos(0, 14));1128 cm.execCommand("goGroupRight"); cm.execCommand("goGroupRight");1129 eqPos(cm.getCursor(), Pos(0, 20));1130 cm.execCommand("goGroupRight");1131 eqPos(cm.getCursor(), Pos(1, 0));1132 cm.execCommand("goGroupRight");1133 eqPos(cm.getCursor(), Pos(1, 2));1134 cm.execCommand("goGroupRight");1135 eqPos(cm.getCursor(), Pos(1, 5));1136 cm.execCommand("goGroupLeft"); cm.execCommand("goGroupLeft");1137 eqPos(cm.getCursor(), Pos(1, 0));1138 cm.execCommand("goGroupLeft");1139 eqPos(cm.getCursor(), Pos(0, 20));1140 cm.execCommand("goGroupLeft");1141 eqPos(cm.getCursor(), Pos(0, 16));1142}, {value: "booo ba---quux. ffff\n abc d"});1143testCM("groupsAndWhitespace", function(cm) {1144 var positions = [Pos(0, 0), Pos(0, 2), Pos(0, 5), Pos(0, 9), Pos(0, 11),1145 Pos(1, 0), Pos(1, 2), Pos(1, 5)];1146 for (var i = 1; i < positions.length; i++) {1147 cm.execCommand("goGroupRight");1148 eqPos(cm.getCursor(), positions[i]);1149 }1150 for (var i = positions.length - 2; i >= 0; i--) {1151 cm.execCommand("goGroupLeft");1152 eqPos(cm.getCursor(), i == 2 ? Pos(0, 6) : positions[i]);1153 }1154}, {value: " foo +++ \n bar"});1155testCM("charMovementCommands", function(cm) {1156 cm.execCommand("goCharLeft"); cm.execCommand("goColumnLeft");1157 eqPos(cm.getCursor(), Pos(0, 0));1158 cm.execCommand("goCharRight"); cm.execCommand("goCharRight");1159 eqPos(cm.getCursor(), Pos(0, 2));1160 cm.setCursor(Pos(1, 0));1161 cm.execCommand("goColumnLeft");1162 eqPos(cm.getCursor(), Pos(1, 0));1163 cm.execCommand("goCharLeft");1164 eqPos(cm.getCursor(), Pos(0, 5));1165 cm.execCommand("goColumnRight");1166 eqPos(cm.getCursor(), Pos(0, 5));1167 cm.execCommand("goCharRight");1168 eqPos(cm.getCursor(), Pos(1, 0));1169 cm.execCommand("goLineEnd");1170 eqPos(cm.getCursor(), Pos(1, 5));1171 cm.execCommand("goLineStartSmart");1172 eqPos(cm.getCursor(), Pos(1, 1));1173 cm.execCommand("goLineStartSmart");1174 eqPos(cm.getCursor(), Pos(1, 0));1175 cm.setCursor(Pos(2, 0));1176 cm.execCommand("goCharRight"); cm.execCommand("goColumnRight");1177 eqPos(cm.getCursor(), Pos(2, 0));1178}, {value: "line1\n ine2\n"});1179testCM("verticalMovementCommands", function(cm) {1180 cm.execCommand("goLineUp");1181 eqPos(cm.getCursor(), Pos(0, 0));1182 cm.execCommand("goLineDown");1183 if (!phantom) // This fails in PhantomJS, though not in a real Webkit1184 eqPos(cm.getCursor(), Pos(1, 0));1185 cm.setCursor(Pos(1, 12));1186 cm.execCommand("goLineDown");1187 eqPos(cm.getCursor(), Pos(2, 5));1188 cm.execCommand("goLineDown");1189 eqPos(cm.getCursor(), Pos(3, 0));1190 cm.execCommand("goLineUp");1191 eqPos(cm.getCursor(), Pos(2, 5));1192 cm.execCommand("goLineUp");1193 eqPos(cm.getCursor(), Pos(1, 12));1194 cm.execCommand("goPageDown");1195 eqPos(cm.getCursor(), Pos(5, 0));1196 cm.execCommand("goPageDown"); cm.execCommand("goLineDown");1197 eqPos(cm.getCursor(), Pos(5, 0));1198 cm.execCommand("goPageUp");1199 eqPos(cm.getCursor(), Pos(0, 0));1200}, {value: "line1\nlong long line2\nline3\n\nline5\n"});1201testCM("verticalMovementCommandsWrapping", function(cm) {1202 cm.setSize(120);1203 cm.setCursor(Pos(0, 5));1204 cm.execCommand("goLineDown");1205 eq(cm.getCursor().line, 0);1206 is(cm.getCursor().ch > 5, "moved beyond wrap");1207 for (var i = 0; ; ++i) {1208 is(i < 20, "no endless loop");1209 cm.execCommand("goLineDown");1210 var cur = cm.getCursor();1211 if (cur.line == 1) eq(cur.ch, 5);1212 if (cur.line == 2) { eq(cur.ch, 1); break; }1213 }1214}, {value: "a very long line that wraps around somehow so that we can test cursor movement\nshortone\nk",1215 lineWrapping: true});1216testCM("rtlMovement", function(cm) {1217 forEach(["خحج", "خحabcخحج", "abخحخحجcd", "abخde", "abخح2342خ1حج", "خ1ح2خح3حxج",1218 "خحcd", "1خحcd", "abcdeح1ج", "خمرحبها مها!", "foobarر", "خ ة ق",1219 "<img src=\"/בדיקה3.jpg\">"], function(line) {1220 var inv = line.charAt(0) == "خ";1221 cm.setValue(line + "\n"); cm.execCommand(inv ? "goLineEnd" : "goLineStart");1222 var cursors = byClassName(cm.getWrapperElement(), "CodeMirror-cursors")[0];1223 var cursor = cursors.firstChild;1224 var prevX = cursor.offsetLeft, prevY = cursor.offsetTop;1225 for (var i = 0; i <= line.length; ++i) {1226 cm.execCommand("goCharRight");1227 cursor = cursors.firstChild;1228 if (i == line.length) is(cursor.offsetTop > prevY, "next line");1229 else is(cursor.offsetLeft > prevX, "moved right");1230 prevX = cursor.offsetLeft; prevY = cursor.offsetTop;1231 }1232 cm.setCursor(0, 0); cm.execCommand(inv ? "goLineStart" : "goLineEnd");1233 prevX = cursors.firstChild.offsetLeft;1234 for (var i = 0; i < line.length; ++i) {1235 cm.execCommand("goCharLeft");1236 cursor = cursors.firstChild;1237 is(cursor.offsetLeft < prevX, "moved left");1238 prevX = cursor.offsetLeft;1239 }1240 });1241}, null, ie_lt9);1242// Verify that updating a line clears its bidi ordering1243testCM("bidiUpdate", function(cm) {1244 cm.setCursor(Pos(0, 2));1245 cm.replaceSelection("خحج", "start");1246 cm.execCommand("goCharRight");1247 eqPos(cm.getCursor(), Pos(0, 4));1248}, {value: "abcd\n"});1249testCM("movebyTextUnit", function(cm) {1250 cm.setValue("בְּרֵאשִ\nééé́\n");1251 cm.execCommand("goLineEnd");1252 for (var i = 0; i < 4; ++i) cm.execCommand("goCharRight");1253 eqPos(cm.getCursor(), Pos(0, 0));1254 cm.execCommand("goCharRight");1255 eqPos(cm.getCursor(), Pos(1, 0));1256 cm.execCommand("goCharRight");1257 cm.execCommand("goCharRight");1258 eqPos(cm.getCursor(), Pos(1, 4));1259 cm.execCommand("goCharRight");1260 eqPos(cm.getCursor(), Pos(1, 7));1261});1262testCM("lineChangeEvents", function(cm) {1263 addDoc(cm, 3, 5);1264 var log = [], want = ["ch 0", "ch 1", "del 2", "ch 0", "ch 0", "del 1", "del 3", "del 4"];1265 for (var i = 0; i < 5; ++i) {1266 CodeMirror.on(cm.getLineHandle(i), "delete", function(i) {1267 return function() {log.push("del " + i);};1268 }(i));1269 CodeMirror.on(cm.getLineHandle(i), "change", function(i) {1270 return function() {log.push("ch " + i);};1271 }(i));1272 }1273 cm.replaceRange("x", Pos(0, 1));1274 cm.replaceRange("xy", Pos(1, 1), Pos(2));1275 cm.replaceRange("foo\nbar", Pos(0, 1));1276 cm.replaceRange("", Pos(0, 0), Pos(cm.lineCount()));1277 eq(log.length, want.length, "same length");1278 for (var i = 0; i < log.length; ++i)1279 eq(log[i], want[i]);1280});1281testCM("scrollEntirelyToRight", function(cm) {1282 if (phantom) return;1283 addDoc(cm, 500, 2);1284 cm.setCursor(Pos(0, 500));1285 var wrap = cm.getWrapperElement(), cur = byClassName(wrap, "CodeMirror-cursor")[0];1286 is(wrap.getBoundingClientRect().right > cur.getBoundingClientRect().left);1287});1288testCM("lineWidgets", function(cm) {1289 addDoc(cm, 500, 3);1290 var last = cm.charCoords(Pos(2, 0));1291 var node = document.createElement("div");1292 node.innerHTML = "hi";1293 var widget = cm.addLineWidget(1, node);1294 is(last.top < cm.charCoords(Pos(2, 0)).top, "took up space");1295 cm.setCursor(Pos(1, 1));1296 cm.execCommand("goLineDown");1297 eqPos(cm.getCursor(), Pos(2, 1));1298 cm.execCommand("goLineUp");1299 eqPos(cm.getCursor(), Pos(1, 1));1300});1301testCM("lineWidgetFocus", function(cm) {1302 var place = document.getElementById("testground");1303 place.className = "offscreen";1304 try {1305 addDoc(cm, 500, 10);1306 var node = document.createElement("input");1307 var widget = cm.addLineWidget(1, node);1308 node.focus();1309 eq(document.activeElement, node);1310 cm.replaceRange("new stuff", Pos(1, 0));1311 eq(document.activeElement, node);1312 } finally {1313 place.className = "";1314 }1315});1316testCM("lineWidgetCautiousRedraw", function(cm) {1317 var node = document.createElement("div");1318 node.innerHTML = "hahah";1319 var w = cm.addLineWidget(0, node);1320 var redrawn = false;1321 w.on("redraw", function() { redrawn = true; });1322 cm.replaceSelection("0");1323 is(!redrawn);1324}, {value: "123\n456"});1325var knownScrollbarWidth;1326function scrollbarWidth(measure) {1327 if (knownScrollbarWidth != null) return knownScrollbarWidth;1328 var div = document.createElement('div');1329 div.style.cssText = "width: 50px; height: 50px; overflow-x: scroll";1330 document.body.appendChild(div);1331 knownScrollbarWidth = div.offsetHeight - div.clientHeight;1332 document.body.removeChild(div);1333 return knownScrollbarWidth || 0;1334}1335testCM("lineWidgetChanged", function(cm) {1336 addDoc(cm, 2, 300);1337 var halfScrollbarWidth = scrollbarWidth(cm.display.measure)/2;1338 cm.setOption('lineNumbers', true);1339 cm.setSize(600, cm.defaultTextHeight() * 50);1340 cm.scrollTo(null, cm.heightAtLine(125, "local"));1341 var expectedWidgetHeight = 60;1342 var expectedLinesInWidget = 3;1343 function w() {1344 var node = document.createElement("div");1345 // we use these children with just under half width of the line to check measurements are made with correct width1346 // when placed in the measure div.1347 // If the widget is measured at a width much narrower than it is displayed at, the underHalf children will span two lines and break the test.1348 // If the widget is measured at a width much wider than it is displayed at, the overHalf children will combine and break the test.1349 // Note that this test only checks widgets where coverGutter is true, because these require extra styling to get the width right.1350 // It may also be worthwhile to check this for non-coverGutter widgets.1351 // Visually:1352 // Good:1353 // | ------------- display width ------------- |1354 // | ------- widget-width when measured ------ |1355 // | | -- under-half -- | | -- under-half -- | | 1356 // | | --- over-half --- | |1357 // | | --- over-half --- | |1358 // Height: measured as 3 lines, same as it will be when actually displayed1359 // Bad (too narrow):1360 // | ------------- display width ------------- |1361 // | ------ widget-width when measured ----- | < -- uh oh1362 // | | -- under-half -- | |1363 // | | -- under-half -- | | < -- when measured, shoved to next line1364 // | | --- over-half --- | |1365 // | | --- over-half --- | |1366 // Height: measured as 4 lines, more than expected . Will be displayed as 3 lines!1367 // Bad (too wide):1368 // | ------------- display width ------------- |1369 // | -------- widget-width when measured ------- | < -- uh oh1370 // | | -- under-half -- | | -- under-half -- | | 1371 // | | --- over-half --- | | --- over-half --- | | < -- when measured, combined on one line1372 // Height: measured as 2 lines, less than expected. Will be displayed as 3 lines!1373 var barelyUnderHalfWidthHtml = '<div style="display: inline-block; height: 1px; width: '+(285 - halfScrollbarWidth)+'px;"></div>';1374 var barelyOverHalfWidthHtml = '<div style="display: inline-block; height: 1px; width: '+(305 - halfScrollbarWidth)+'px;"></div>';1375 node.innerHTML = new Array(3).join(barelyUnderHalfWidthHtml) + new Array(3).join(barelyOverHalfWidthHtml);1376 node.style.cssText = "background: yellow;font-size:0;line-height: " + (expectedWidgetHeight/expectedLinesInWidget) + "px;";1377 return node;1378 }1379 var info0 = cm.getScrollInfo();1380 var w0 = cm.addLineWidget(0, w(), { coverGutter: true });1381 var w150 = cm.addLineWidget(150, w(), { coverGutter: true });1382 var w300 = cm.addLineWidget(300, w(), { coverGutter: true });1383 var info1 = cm.getScrollInfo();1384 eq(info0.height + (3 * expectedWidgetHeight), info1.height);1385 eq(info0.top + expectedWidgetHeight, info1.top);1386 expectedWidgetHeight = 12;1387 w0.node.style.lineHeight = w150.node.style.lineHeight = w300.node.style.lineHeight = (expectedWidgetHeight/expectedLinesInWidget) + "px";1388 w0.changed(); w150.changed(); w300.changed();1389 var info2 = cm.getScrollInfo();1390 eq(info0.height + (3 * expectedWidgetHeight), info2.height);1391 eq(info0.top + expectedWidgetHeight, info2.top);1392});1393testCM("getLineNumber", function(cm) {1394 addDoc(cm, 2, 20);1395 var h1 = cm.getLineHandle(1);1396 eq(cm.getLineNumber(h1), 1);1397 cm.replaceRange("hi\nbye\n", Pos(0, 0));1398 eq(cm.getLineNumber(h1), 3);1399 cm.setValue("");1400 eq(cm.getLineNumber(h1), null);1401});1402testCM("jumpTheGap", function(cm) {1403 if (phantom) return;1404 var longLine = "abcdef ghiklmnop qrstuvw xyz ";1405 longLine += longLine; longLine += longLine; longLine += longLine;1406 cm.replaceRange(longLine, Pos(2, 0), Pos(2));1407 cm.setSize("200px", null);1408 cm.getWrapperElement().style.lineHeight = 2;1409 cm.refresh();1410 cm.setCursor(Pos(0, 1));1411 cm.execCommand("goLineDown");1412 eqPos(cm.getCursor(), Pos(1, 1));1413 cm.execCommand("goLineDown");1414 eqPos(cm.getCursor(), Pos(2, 1));1415 cm.execCommand("goLineDown");1416 eq(cm.getCursor().line, 2);1417 is(cm.getCursor().ch > 1);1418 cm.execCommand("goLineUp");1419 eqPos(cm.getCursor(), Pos(2, 1));1420 cm.execCommand("goLineUp");1421 eqPos(cm.getCursor(), Pos(1, 1));1422 var node = document.createElement("div");1423 node.innerHTML = "hi"; node.style.height = "30px";1424 cm.addLineWidget(0, node);1425 cm.addLineWidget(1, node.cloneNode(true), {above: true});1426 cm.setCursor(Pos(0, 2));1427 cm.execCommand("goLineDown");1428 eqPos(cm.getCursor(), Pos(1, 2));1429 cm.execCommand("goLineUp");1430 eqPos(cm.getCursor(), Pos(0, 2));1431}, {lineWrapping: true, value: "abc\ndef\nghi\njkl\n"});1432testCM("addLineClass", function(cm) {1433 function cls(line, text, bg, wrap) {1434 var i = cm.lineInfo(line);1435 eq(i.textClass, text);1436 eq(i.bgClass, bg);1437 eq(i.wrapClass, wrap);1438 }1439 cm.addLineClass(0, "text", "foo");1440 cm.addLineClass(0, "text", "bar");1441 cm.addLineClass(1, "background", "baz");1442 cm.addLineClass(1, "wrap", "foo");1443 cls(0, "foo bar", null, null);1444 cls(1, null, "baz", "foo");1445 var lines = cm.display.lineDiv;1446 eq(byClassName(lines, "foo").length, 2);1447 eq(byClassName(lines, "bar").length, 1);1448 eq(byClassName(lines, "baz").length, 1);1449 cm.removeLineClass(0, "text", "foo");1450 cls(0, "bar", null, null);1451 cm.removeLineClass(0, "text", "foo");1452 cls(0, "bar", null, null);1453 cm.removeLineClass(0, "text", "bar");1454 cls(0, null, null, null);1455 cm.addLineClass(1, "wrap", "quux");1456 cls(1, null, "baz", "foo quux");1457 cm.removeLineClass(1, "wrap");1458 cls(1, null, "baz", null);1459}, {value: "hohoho\n"});1460testCM("atomicMarker", function(cm) {1461 addDoc(cm, 10, 10);1462 function atom(ll, cl, lr, cr, li, ri) {1463 return cm.markText(Pos(ll, cl), Pos(lr, cr),1464 {atomic: true, inclusiveLeft: li, inclusiveRight: ri});1465 }1466 var m = atom(0, 1, 0, 5);1467 cm.setCursor(Pos(0, 1));1468 cm.execCommand("goCharRight");1469 eqPos(cm.getCursor(), Pos(0, 5));1470 cm.execCommand("goCharLeft");1471 eqPos(cm.getCursor(), Pos(0, 1));1472 m.clear();1473 m = atom(0, 0, 0, 5, true);1474 eqPos(cm.getCursor(), Pos(0, 5), "pushed out");1475 cm.execCommand("goCharLeft");1476 eqPos(cm.getCursor(), Pos(0, 5));1477 m.clear();1478 m = atom(8, 4, 9, 10, false, true);1479 cm.setCursor(Pos(9, 8));1480 eqPos(cm.getCursor(), Pos(8, 4), "set");1481 cm.execCommand("goCharRight");1482 eqPos(cm.getCursor(), Pos(8, 4), "char right");1483 cm.execCommand("goLineDown");1484 eqPos(cm.getCursor(), Pos(8, 4), "line down");1485 cm.execCommand("goCharLeft");1486 eqPos(cm.getCursor(), Pos(8, 3));1487 m.clear();1488 m = atom(1, 1, 3, 8);1489 cm.setCursor(Pos(0, 0));1490 cm.setCursor(Pos(2, 0));1491 eqPos(cm.getCursor(), Pos(3, 8));1492 cm.execCommand("goCharLeft");1493 eqPos(cm.getCursor(), Pos(1, 1));1494 cm.execCommand("goCharRight");1495 eqPos(cm.getCursor(), Pos(3, 8));1496 cm.execCommand("goLineUp");1497 eqPos(cm.getCursor(), Pos(1, 1));1498 cm.execCommand("goLineDown");1499 eqPos(cm.getCursor(), Pos(3, 8));1500 cm.execCommand("delCharBefore");1501 eq(cm.getValue().length, 80, "del chunk");1502 m = atom(3, 0, 5, 5);1503 cm.setCursor(Pos(3, 0));1504 cm.execCommand("delWordAfter");1505 eq(cm.getValue().length, 53, "del chunk");1506});1507testCM("selectionBias", function(cm) {1508 cm.markText(Pos(0, 1), Pos(0, 3), {atomic: true});1509 cm.setCursor(Pos(0, 2));1510 eqPos(cm.getCursor(), Pos(0, 3));1511 cm.setCursor(Pos(0, 2));1512 eqPos(cm.getCursor(), Pos(0, 1));1513 cm.setCursor(Pos(0, 2), null, {bias: -1});1514 eqPos(cm.getCursor(), Pos(0, 1));1515 cm.setCursor(Pos(0, 4));1516 cm.setCursor(Pos(0, 2), null, {bias: 1});1517 eqPos(cm.getCursor(), Pos(0, 3));1518}, {value: "12345"});1519testCM("selectionHomeEnd", function(cm) {1520 cm.markText(Pos(1, 0), Pos(1, 1), {atomic: true, inclusiveLeft: true});1521 cm.markText(Pos(1, 3), Pos(1, 4), {atomic: true, inclusiveRight: true});1522 cm.setCursor(Pos(1, 2));1523 cm.execCommand("goLineStart");1524 eqPos(cm.getCursor(), Pos(1, 1));1525 cm.execCommand("goLineEnd");1526 eqPos(cm.getCursor(), Pos(1, 3));1527}, {value: "ab\ncdef\ngh"});1528testCM("readOnlyMarker", function(cm) {1529 function mark(ll, cl, lr, cr, at) {1530 return cm.markText(Pos(ll, cl), Pos(lr, cr),1531 {readOnly: true, atomic: at});1532 }1533 var m = mark(0, 1, 0, 4);1534 cm.setCursor(Pos(0, 2));1535 cm.replaceSelection("hi", "end");1536 eqPos(cm.getCursor(), Pos(0, 2));1537 eq(cm.getLine(0), "abcde");1538 cm.execCommand("selectAll");1539 cm.replaceSelection("oops", "around");1540 eq(cm.getValue(), "oopsbcd");1541 cm.undo();1542 eqPos(m.find().from, Pos(0, 1));1543 eqPos(m.find().to, Pos(0, 4));1544 m.clear();1545 cm.setCursor(Pos(0, 2));1546 cm.replaceSelection("hi", "around");1547 eq(cm.getLine(0), "abhicde");1548 eqPos(cm.getCursor(), Pos(0, 4));1549 m = mark(0, 2, 2, 2, true);1550 cm.setSelection(Pos(1, 1), Pos(2, 4));1551 cm.replaceSelection("t", "end");1552 eqPos(cm.getCursor(), Pos(2, 3));1553 eq(cm.getLine(2), "klto");1554 cm.execCommand("goCharLeft");1555 cm.execCommand("goCharLeft");1556 eqPos(cm.getCursor(), Pos(0, 2));1557 cm.setSelection(Pos(0, 1), Pos(0, 3));1558 cm.replaceSelection("xx", "around");1559 eqPos(cm.getCursor(), Pos(0, 3));1560 eq(cm.getLine(0), "axxhicde");1561}, {value: "abcde\nfghij\nklmno\n"});1562testCM("dirtyBit", function(cm) {1563 eq(cm.isClean(), true);1564 cm.replaceSelection("boo", null, "test");1565 eq(cm.isClean(), false);1566 cm.undo();1567 eq(cm.isClean(), true);1568 cm.replaceSelection("boo", null, "test");1569 cm.replaceSelection("baz", null, "test");1570 cm.undo();1571 eq(cm.isClean(), false);1572 cm.markClean();1573 eq(cm.isClean(), true);1574 cm.undo();1575 eq(cm.isClean(), false);1576 cm.redo();1577 eq(cm.isClean(), true);1578});1579testCM("changeGeneration", function(cm) {1580 cm.replaceSelection("x");1581 var softGen = cm.changeGeneration();1582 cm.replaceSelection("x");1583 cm.undo();1584 eq(cm.getValue(), "");1585 is(!cm.isClean(softGen));1586 cm.replaceSelection("x");1587 var hardGen = cm.changeGeneration(true);1588 cm.replaceSelection("x");1589 cm.undo();1590 eq(cm.getValue(), "x");1591 is(cm.isClean(hardGen));1592});1593testCM("addKeyMap", function(cm) {1594 function sendKey(code) {1595 cm.triggerOnKeyDown({type: "keydown", keyCode: code,1596 preventDefault: function(){}, stopPropagation: function(){}});1597 }1598 sendKey(39);1599 eqPos(cm.getCursor(), Pos(0, 1));1600 var test = 0;1601 var map1 = {Right: function() { ++test; }}, map2 = {Right: function() { test += 10; }}1602 cm.addKeyMap(map1);1603 sendKey(39);1604 eqPos(cm.getCursor(), Pos(0, 1));1605 eq(test, 1);1606 cm.addKeyMap(map2, true);1607 sendKey(39);1608 eq(test, 2);1609 cm.removeKeyMap(map1);1610 sendKey(39);1611 eq(test, 12);1612 cm.removeKeyMap(map2);1613 sendKey(39);1614 eq(test, 12);1615 eqPos(cm.getCursor(), Pos(0, 2));1616 cm.addKeyMap({Right: function() { test = 55; }, name: "mymap"});1617 sendKey(39);1618 eq(test, 55);1619 cm.removeKeyMap("mymap");1620 sendKey(39);1621 eqPos(cm.getCursor(), Pos(0, 3));1622}, {value: "abc"});1623testCM("findPosH", function(cm) {1624 forEach([{from: Pos(0, 0), to: Pos(0, 1), by: 1},1625 {from: Pos(0, 0), to: Pos(0, 0), by: -1, hitSide: true},1626 {from: Pos(0, 0), to: Pos(0, 4), by: 1, unit: "word"},1627 {from: Pos(0, 0), to: Pos(0, 8), by: 2, unit: "word"},1628 {from: Pos(0, 0), to: Pos(2, 0), by: 20, unit: "word", hitSide: true},1629 {from: Pos(0, 7), to: Pos(0, 5), by: -1, unit: "word"},1630 {from: Pos(0, 4), to: Pos(0, 8), by: 1, unit: "word"},1631 {from: Pos(1, 0), to: Pos(1, 18), by: 3, unit: "word"},1632 {from: Pos(1, 22), to: Pos(1, 5), by: -3, unit: "word"},1633 {from: Pos(1, 15), to: Pos(1, 10), by: -5},1634 {from: Pos(1, 15), to: Pos(1, 10), by: -5, unit: "column"},1635 {from: Pos(1, 15), to: Pos(1, 0), by: -50, unit: "column", hitSide: true},1636 {from: Pos(1, 15), to: Pos(1, 24), by: 50, unit: "column", hitSide: true},1637 {from: Pos(1, 15), to: Pos(2, 0), by: 50, hitSide: true}], function(t) {1638 var r = cm.findPosH(t.from, t.by, t.unit || "char");1639 eqPos(r, t.to);1640 eq(!!r.hitSide, !!t.hitSide);1641 });1642}, {value: "line one\nline two.something.other\n"});1643testCM("beforeChange", function(cm) {1644 cm.on("beforeChange", function(cm, change) {1645 var text = [];1646 for (var i = 0; i < change.text.length; ++i)1647 text.push(change.text[i].replace(/\s/g, "_"));1648 change.update(null, null, text);1649 });1650 cm.setValue("hello, i am a\nnew document\n");1651 eq(cm.getValue(), "hello,_i_am_a\nnew_document\n");1652 CodeMirror.on(cm.getDoc(), "beforeChange", function(doc, change) {1653 if (change.from.line == 0) change.cancel();1654 });1655 cm.setValue("oops"); // Canceled1656 eq(cm.getValue(), "hello,_i_am_a\nnew_document\n");1657 cm.replaceRange("hey hey hey", Pos(1, 0), Pos(2, 0));1658 eq(cm.getValue(), "hello,_i_am_a\nhey_hey_hey");1659}, {value: "abcdefghijk"});1660testCM("beforeChangeUndo", function(cm) {1661 cm.replaceRange("hi", Pos(0, 0), Pos(0));1662 cm.replaceRange("bye", Pos(0, 0), Pos(0));1663 eq(cm.historySize().undo, 2);1664 cm.on("beforeChange", function(cm, change) {1665 is(!change.update);1666 change.cancel();1667 });1668 cm.undo();1669 eq(cm.historySize().undo, 0);1670 eq(cm.getValue(), "bye\ntwo");1671}, {value: "one\ntwo"});1672testCM("beforeSelectionChange", function(cm) {1673 function notAtEnd(cm, pos) {1674 var len = cm.getLine(pos.line).length;1675 if (!len || pos.ch == len) return Pos(pos.line, pos.ch - 1);1676 return pos;1677 }1678 cm.on("beforeSelectionChange", function(cm, obj) {1679 obj.update([{anchor: notAtEnd(cm, obj.ranges[0].anchor),1680 head: notAtEnd(cm, obj.ranges[0].head)}]);1681 });1682 addDoc(cm, 10, 10);1683 cm.execCommand("goLineEnd");1684 eqPos(cm.getCursor(), Pos(0, 9));1685 cm.execCommand("selectAll");1686 eqPos(cm.getCursor("start"), Pos(0, 0));1687 eqPos(cm.getCursor("end"), Pos(9, 9));1688});1689testCM("change_removedText", function(cm) {1690 cm.setValue("abc\ndef");1691 var removedText = [];1692 cm.on("change", function(cm, change) {1693 removedText.push(change.removed);1694 });1695 cm.operation(function() {1696 cm.replaceRange("xyz", Pos(0, 0), Pos(1,1));1697 cm.replaceRange("123", Pos(0,0));1698 });1699 eq(removedText.length, 2);1700 eq(removedText[0].join("\n"), "abc\nd");1701 eq(removedText[1].join("\n"), "");1702 var removedText = [];1703 cm.undo();1704 eq(removedText.length, 2);1705 eq(removedText[0].join("\n"), "123");1706 eq(removedText[1].join("\n"), "xyz");1707 var removedText = [];1708 cm.redo();1709 eq(removedText.length, 2);1710 eq(removedText[0].join("\n"), "abc\nd");1711 eq(removedText[1].join("\n"), "");1712});1713testCM("lineStyleFromMode", function(cm) {1714 CodeMirror.defineMode("test_mode", function() {1715 return {token: function(stream) {1716 if (stream.match(/^\[[^\]]*\]/)) return " line-brackets ";1717 if (stream.match(/^\([^\)]*\)/)) return " line-background-parens ";1718 if (stream.match(/^<[^>]*>/)) return " span line-line line-background-bg ";1719 stream.match(/^\s+|^\S+/);1720 }};1721 });1722 cm.setOption("mode", "test_mode");1723 var bracketElts = byClassName(cm.getWrapperElement(), "brackets");1724 eq(bracketElts.length, 1, "brackets count");1725 eq(bracketElts[0].nodeName, "PRE");1726 is(!/brackets.*brackets/.test(bracketElts[0].className));1727 var parenElts = byClassName(cm.getWrapperElement(), "parens");1728 eq(parenElts.length, 1, "parens count");1729 eq(parenElts[0].nodeName, "DIV");1730 is(!/parens.*parens/.test(parenElts[0].className));1731 eq(parenElts[0].parentElement.nodeName, "DIV");1732 eq(byClassName(cm.getWrapperElement(), "bg").length, 1);1733 eq(byClassName(cm.getWrapperElement(), "line").length, 1);1734 var spanElts = byClassName(cm.getWrapperElement(), "cm-span");1735 eq(spanElts.length, 2);1736 is(/^\s*cm-span\s*$/.test(spanElts[0].className));1737}, {value: "line1: [br] [br]\nline2: (par) (par)\nline3: <tag> <tag>"});1738testCM("lineStyleFromBlankLine", function(cm) {1739 CodeMirror.defineMode("lineStyleFromBlankLine_mode", function() {1740 return {token: function(stream) { stream.skipToEnd(); return "comment"; },1741 blankLine: function() { return "line-blank"; }};1742 });1743 cm.setOption("mode", "lineStyleFromBlankLine_mode");1744 var blankElts = byClassName(cm.getWrapperElement(), "blank");1745 eq(blankElts.length, 1);1746 eq(blankElts[0].nodeName, "PRE");1747 cm.replaceRange("x", Pos(1, 0));1748 blankElts = byClassName(cm.getWrapperElement(), "blank");1749 eq(blankElts.length, 0);1750}, {value: "foo\n\nbar"});1751CodeMirror.registerHelper("xxx", "a", "A");1752CodeMirror.registerHelper("xxx", "b", "B");1753CodeMirror.defineMode("yyy", function() {1754 return {1755 token: function(stream) { stream.skipToEnd(); },1756 xxx: ["a", "b", "q"]1757 };1758});1759CodeMirror.registerGlobalHelper("xxx", "c", function(m) { return m.enableC; }, "C");1760testCM("helpers", function(cm) {1761 cm.setOption("mode", "yyy");1762 eq(cm.getHelpers(Pos(0, 0), "xxx").join("/"), "A/B");1763 cm.setOption("mode", {name: "yyy", modeProps: {xxx: "b", enableC: true}});1764 eq(cm.getHelpers(Pos(0, 0), "xxx").join("/"), "B/C");1765 cm.setOption("mode", "javascript");1766 eq(cm.getHelpers(Pos(0, 0), "xxx").join("/"), "");1767});1768testCM("selectionHistory", function(cm) {1769 for (var i = 0; i < 3; i++) {1770 cm.setExtending(true);1771 cm.execCommand("goCharRight");1772 cm.setExtending(false);1773 cm.execCommand("goCharRight");1774 cm.execCommand("goCharRight");1775 }1776 cm.execCommand("undoSelection");1777 eq(cm.getSelection(), "c");1778 cm.execCommand("undoSelection");1779 eq(cm.getSelection(), "");1780 eqPos(cm.getCursor(), Pos(0, 4));1781 cm.execCommand("undoSelection");1782 eq(cm.getSelection(), "b");1783 cm.execCommand("redoSelection");1784 eq(cm.getSelection(), "");1785 eqPos(cm.getCursor(), Pos(0, 4));1786 cm.execCommand("redoSelection");1787 eq(cm.getSelection(), "c");1788 cm.execCommand("redoSelection");1789 eq(cm.getSelection(), "");1790 eqPos(cm.getCursor(), Pos(0, 6));1791}, {value: "a b c d"});1792testCM("selectionChangeReducesRedo", function(cm) {1793 cm.replaceSelection("X");1794 cm.execCommand("goCharRight");1795 cm.undoSelection();1796 cm.execCommand("selectAll");1797 cm.undoSelection();1798 eq(cm.getValue(), "Xabc");1799 eqPos(cm.getCursor(), Pos(0, 1));1800 cm.undoSelection();1801 eq(cm.getValue(), "abc");1802}, {value: "abc"});1803testCM("selectionHistoryNonOverlapping", function(cm) {1804 cm.setSelection(Pos(0, 0), Pos(0, 1));1805 cm.setSelection(Pos(0, 2), Pos(0, 3));1806 cm.execCommand("undoSelection");1807 eqPos(cm.getCursor("anchor"), Pos(0, 0));1808 eqPos(cm.getCursor("head"), Pos(0, 1));1809}, {value: "1234"});1810testCM("cursorMotionSplitsHistory", function(cm) {1811 cm.replaceSelection("a");1812 cm.execCommand("goCharRight");1813 cm.replaceSelection("b");1814 cm.replaceSelection("c");1815 cm.undo();1816 eq(cm.getValue(), "a1234");1817 eqPos(cm.getCursor(), Pos(0, 2));1818 cm.undo();1819 eq(cm.getValue(), "1234");1820 eqPos(cm.getCursor(), Pos(0, 0));1821}, {value: "1234"});1822testCM("selChangeInOperationDoesNotSplit", function(cm) {1823 for (var i = 0; i < 4; i++) {1824 cm.operation(function() {1825 cm.replaceSelection("x");1826 cm.setCursor(Pos(0, cm.getCursor().ch - 1));1827 });1828 }1829 eqPos(cm.getCursor(), Pos(0, 0));1830 eq(cm.getValue(), "xxxxa");1831 cm.undo();1832 eq(cm.getValue(), "a");1833}, {value: "a"});1834testCM("alwaysMergeSelEventWithChangeOrigin", function(cm) {1835 cm.replaceSelection("U", null, "foo");1836 cm.setSelection(Pos(0, 0), Pos(0, 1), {origin: "foo"});1837 cm.undoSelection();1838 eq(cm.getValue(), "a");1839 cm.replaceSelection("V", null, "foo");1840 cm.setSelection(Pos(0, 0), Pos(0, 1), {origin: "bar"});1841 cm.undoSelection();1842 eq(cm.getValue(), "Va");1843}, {value: "a"});1844testCM("getTokenTypeAt", function(cm) {1845 eq(cm.getTokenTypeAt(Pos(0, 0)), "number");1846 eq(cm.getTokenTypeAt(Pos(0, 6)), "string");1847 cm.addOverlay({1848 token: function(stream) {1849 if (stream.match("foo")) return "foo";1850 else stream.next();1851 }1852 });1853 eq(byClassName(cm.getWrapperElement(), "cm-foo").length, 1);1854 eq(cm.getTokenTypeAt(Pos(0, 6)), "string");1855}, {value: "1 + 'foo'", mode: "javascript"});1856testCM("resizeLineWidget", function(cm) {1857 addDoc(cm, 200, 3);1858 var widget = document.createElement("pre");1859 widget.innerHTML = "imwidget";1860 widget.style.background = "yellow";1861 cm.addLineWidget(1, widget, {noHScroll: true});1862 cm.setSize(40);1863 is(widget.parentNode.offsetWidth < 42);1864});1865testCM("combinedOperations", function(cm) {1866 var place = document.getElementById("testground");1867 var other = CodeMirror(place, {value: "123"});1868 try {1869 cm.operation(function() {1870 cm.addLineClass(0, "wrap", "foo");1871 other.addLineClass(0, "wrap", "foo");1872 });1873 eq(byClassName(cm.getWrapperElement(), "foo").length, 1);1874 eq(byClassName(other.getWrapperElement(), "foo").length, 1);1875 cm.operation(function() {1876 cm.removeLineClass(0, "wrap", "foo");1877 other.removeLineClass(0, "wrap", "foo");1878 });1879 eq(byClassName(cm.getWrapperElement(), "foo").length, 0);1880 eq(byClassName(other.getWrapperElement(), "foo").length, 0);1881 } finally {1882 place.removeChild(other.getWrapperElement());1883 }1884}, {value: "abc"});1885testCM("eventOrder", function(cm) {1886 var seen = [];1887 cm.on("change", function() {1888 if (!seen.length) cm.replaceSelection(".");1889 seen.push("change");1890 });1891 cm.on("cursorActivity", function() {1892 cm.replaceSelection("!");1893 seen.push("activity");1894 });1895 cm.replaceSelection("/");1896 eq(seen.join(","), "change,change,activity,change");...

Full Screen

Full Screen

multi_test.js

Source:multi_test.js Github

copy

Full Screen

1(function() {2 namespace = "multi_";3 function hasSelections(cm) {4 var sels = cm.listSelections();5 var given = (arguments.length - 1) / 4;6 if (sels.length != given)7 throw new Failure("expected " + given + " selections, found " + sels.length);8 for (var i = 0, p = 1; i < given; i++, p += 4) {9 var anchor = Pos(arguments[p], arguments[p + 1]);10 var head = Pos(arguments[p + 2], arguments[p + 3]);11 eqPos(sels[i].anchor, anchor, "anchor of selection " + i);12 eqPos(sels[i].head, head, "head of selection " + i);13 }14 }15 function hasCursors(cm) {16 var sels = cm.listSelections();17 var given = (arguments.length - 1) / 2;18 if (sels.length != given)19 throw new Failure("expected " + given + " selections, found " + sels.length);20 for (var i = 0, p = 1; i < given; i++, p += 2) {21 eqPos(sels[i].anchor, sels[i].head, "something selected for " + i);22 var head = Pos(arguments[p], arguments[p + 1]);23 eqPos(sels[i].head, head, "selection " + i);24 }25 }26 testCM("getSelection", function(cm) {27 select(cm, {anchor: Pos(0, 0), head: Pos(1, 2)}, {anchor: Pos(2, 2), head: Pos(2, 0)});28 eq(cm.getSelection(), "1234\n56\n90");29 eq(cm.getSelection(false).join("|"), "1234|56|90");30 eq(cm.getSelections().join("|"), "1234\n56|90");31 }, {value: "1234\n5678\n90"});32 testCM("setSelection", function(cm) {33 select(cm, Pos(3, 0), Pos(0, 0), {anchor: Pos(2, 5), head: Pos(1, 0)});34 hasSelections(cm, 0, 0, 0, 0,35 2, 5, 1, 0,36 3, 0, 3, 0);37 cm.setSelection(Pos(1, 2), Pos(1, 1));38 hasSelections(cm, 1, 2, 1, 1);39 select(cm, {anchor: Pos(1, 1), head: Pos(2, 4)},40 {anchor: Pos(0, 0), head: Pos(1, 3)},41 Pos(3, 0), Pos(2, 2));42 hasSelections(cm, 0, 0, 2, 4,43 3, 0, 3, 0);44 cm.setSelections([{anchor: Pos(0, 1), head: Pos(0, 2)},45 {anchor: Pos(1, 1), head: Pos(1, 2)},46 {anchor: Pos(2, 1), head: Pos(2, 2)}], 1);47 eqPos(cm.getCursor("head"), Pos(1, 2));48 eqPos(cm.getCursor("anchor"), Pos(1, 1));49 eqPos(cm.getCursor("from"), Pos(1, 1));50 eqPos(cm.getCursor("to"), Pos(1, 2));51 cm.setCursor(Pos(1, 1));52 hasCursors(cm, 1, 1);53 }, {value: "abcde\nabcde\nabcde\n"});54 testCM("somethingSelected", function(cm) {55 select(cm, Pos(0, 1), {anchor: Pos(0, 3), head: Pos(0, 5)});56 eq(cm.somethingSelected(), true);57 select(cm, Pos(0, 1), Pos(0, 3), Pos(0, 5));58 eq(cm.somethingSelected(), false);59 }, {value: "123456789"});60 testCM("extendSelection", function(cm) {61 select(cm, Pos(0, 1), Pos(1, 1), Pos(2, 1));62 cm.setExtending(true);63 cm.extendSelections([Pos(0, 2), Pos(1, 0), Pos(2, 3)]);64 hasSelections(cm, 0, 1, 0, 2,65 1, 1, 1, 0,66 2, 1, 2, 3);67 cm.extendSelection(Pos(2, 4), Pos(2, 0));68 hasSelections(cm, 2, 4, 2, 0);69 }, {value: "1234\n1234\n1234"});70 testCM("addSelection", function(cm) {71 select(cm, Pos(0, 1), Pos(1, 1));72 cm.addSelection(Pos(0, 0), Pos(0, 4));73 hasSelections(cm, 0, 0, 0, 4,74 1, 1, 1, 1);75 cm.addSelection(Pos(2, 2));76 hasSelections(cm, 0, 0, 0, 4,77 1, 1, 1, 1,78 2, 2, 2, 2);79 }, {value: "1234\n1234\n1234"});80 testCM("replaceSelection", function(cm) {81 var selections = [{anchor: Pos(0, 0), head: Pos(0, 1)},82 {anchor: Pos(0, 2), head: Pos(0, 3)},83 {anchor: Pos(0, 4), head: Pos(0, 5)},84 {anchor: Pos(2, 1), head: Pos(2, 4)},85 {anchor: Pos(2, 5), head: Pos(2, 6)}];86 var val = "123456\n123456\n123456";87 cm.setValue(val);88 cm.setSelections(selections);89 cm.replaceSelection("ab", "around");90 eq(cm.getValue(), "ab2ab4ab6\n123456\n1ab5ab");91 hasSelections(cm, 0, 0, 0, 2,92 0, 3, 0, 5,93 0, 6, 0, 8,94 2, 1, 2, 3,95 2, 4, 2, 6);96 cm.setValue(val);97 cm.setSelections(selections);98 cm.replaceSelection("", "around");99 eq(cm.getValue(), "246\n123456\n15");100 hasSelections(cm, 0, 0, 0, 0,101 0, 1, 0, 1,102 0, 2, 0, 2,103 2, 1, 2, 1,104 2, 2, 2, 2);105 cm.setValue(val);106 cm.setSelections(selections);107 cm.replaceSelection("X\nY\nZ", "around");108 hasSelections(cm, 0, 0, 2, 1,109 2, 2, 4, 1,110 4, 2, 6, 1,111 8, 1, 10, 1,112 10, 2, 12, 1);113 cm.replaceSelection("a", "around");114 hasSelections(cm, 0, 0, 0, 1,115 0, 2, 0, 3,116 0, 4, 0, 5,117 2, 1, 2, 2,118 2, 3, 2, 4);119 cm.replaceSelection("xy", "start");120 hasSelections(cm, 0, 0, 0, 0,121 0, 3, 0, 3,122 0, 6, 0, 6,123 2, 1, 2, 1,124 2, 4, 2, 4);125 cm.replaceSelection("z\nf");126 hasSelections(cm, 1, 1, 1, 1,127 2, 1, 2, 1,128 3, 1, 3, 1,129 6, 1, 6, 1,130 7, 1, 7, 1);131 eq(cm.getValue(), "z\nfxy2z\nfxy4z\nfxy6\n123456\n1z\nfxy5z\nfxy");132 });133 function select(cm) {134 var sels = [];135 for (var i = 1; i < arguments.length; i++) {136 var arg = arguments[i];137 if (arg.head) sels.push(arg);138 else sels.push({head: arg, anchor: arg});139 }140 cm.setSelections(sels, sels.length - 1);141 }142 testCM("indentSelection", function(cm) {143 select(cm, Pos(0, 1), Pos(1, 1));144 cm.indentSelection(4);145 eq(cm.getValue(), " foo\n bar\nbaz");146 select(cm, Pos(0, 2), Pos(0, 3), Pos(0, 4));147 cm.indentSelection(-2);148 eq(cm.getValue(), " foo\n bar\nbaz");149 select(cm, {anchor: Pos(0, 0), head: Pos(1, 2)},150 {anchor: Pos(1, 3), head: Pos(2, 0)});151 cm.indentSelection(-2);152 eq(cm.getValue(), "foo\n bar\nbaz");153 }, {value: "foo\nbar\nbaz"});154 testCM("killLine", function(cm) {155 select(cm, Pos(0, 1), Pos(0, 2), Pos(1, 1));156 cm.execCommand("killLine");157 eq(cm.getValue(), "f\nb\nbaz");158 cm.execCommand("killLine");159 eq(cm.getValue(), "fbbaz");160 cm.setValue("foo\nbar\nbaz");161 select(cm, Pos(0, 1), {anchor: Pos(0, 2), head: Pos(2, 1)});162 cm.execCommand("killLine");163 eq(cm.getValue(), "faz");164 }, {value: "foo\nbar\nbaz"});165 testCM("deleteLine", function(cm) {166 select(cm, Pos(0, 0),167 {head: Pos(0, 1), anchor: Pos(2, 0)},168 Pos(4, 0));169 cm.execCommand("deleteLine");170 eq(cm.getValue(), "4\n6\n7");171 select(cm, Pos(2, 1));172 cm.execCommand("deleteLine");173 eq(cm.getValue(), "4\n6\n");174 }, {value: "1\n2\n3\n4\n5\n6\n7"});175 testCM("deleteH", function(cm) {176 select(cm, Pos(0, 4), {anchor: Pos(1, 4), head: Pos(1, 5)});177 cm.execCommand("delWordAfter");178 eq(cm.getValue(), "foo bar baz\nabc ef ghi\n");179 cm.execCommand("delWordAfter");180 eq(cm.getValue(), "foo baz\nabc ghi\n");181 cm.execCommand("delCharBefore");182 cm.execCommand("delCharBefore");183 eq(cm.getValue(), "fo baz\nab ghi\n");184 select(cm, Pos(0, 3), Pos(0, 4), Pos(0, 5));185 cm.execCommand("delWordAfter");186 eq(cm.getValue(), "fo \nab ghi\n");187 }, {value: "foo bar baz\nabc def ghi\n"});188 testCM("goLineStart", function(cm) {189 select(cm, Pos(0, 2), Pos(0, 3), Pos(1, 1));190 cm.execCommand("goLineStart");191 hasCursors(cm, 0, 0, 1, 0);192 select(cm, Pos(1, 1), Pos(0, 1));193 cm.setExtending(true);194 cm.execCommand("goLineStart");195 hasSelections(cm, 0, 1, 0, 0,196 1, 1, 1, 0);197 }, {value: "foo\nbar\nbaz"});198 testCM("moveV", function(cm) {199 select(cm, Pos(0, 2), Pos(1, 2));200 cm.execCommand("goLineDown");201 hasCursors(cm, 1, 2, 2, 2);202 cm.execCommand("goLineUp");203 hasCursors(cm, 0, 2, 1, 2);204 cm.execCommand("goLineUp");205 hasCursors(cm, 0, 0, 0, 2);206 cm.execCommand("goLineUp");207 hasCursors(cm, 0, 0);208 select(cm, Pos(0, 2), Pos(1, 2));209 cm.setExtending(true);210 cm.execCommand("goLineDown");211 hasSelections(cm, 0, 2, 2, 2);212 }, {value: "12345\n12345\n12345"});213 testCM("moveH", function(cm) {214 select(cm, Pos(0, 1), Pos(0, 3), Pos(0, 5), Pos(2, 3));215 cm.execCommand("goCharRight");216 hasCursors(cm, 0, 2, 0, 4, 1, 0, 2, 4);217 cm.execCommand("goCharLeft");218 hasCursors(cm, 0, 1, 0, 3, 0, 5, 2, 3);219 for (var i = 0; i < 15; i++)220 cm.execCommand("goCharRight");221 hasCursors(cm, 2, 4, 2, 5);222 }, {value: "12345\n12345\n12345"});223 testCM("newlineAndIndent", function(cm) {224 select(cm, Pos(0, 5), Pos(1, 5));225 cm.execCommand("newlineAndIndent");226 hasCursors(cm, 1, 2, 3, 2);227 eq(cm.getValue(), "x = [\n 1];\ny = [\n 2];");228 cm.undo();229 eq(cm.getValue(), "x = [1];\ny = [2];");230 hasCursors(cm, 0, 5, 1, 5);231 select(cm, Pos(0, 5), Pos(0, 6));232 cm.execCommand("newlineAndIndent");233 hasCursors(cm, 1, 2, 2, 0);234 eq(cm.getValue(), "x = [\n 1\n];\ny = [2];");235 }, {value: "x = [1];\ny = [2];", mode: "javascript"});236 testCM("goDocStartEnd", function(cm) {237 select(cm, Pos(0, 1), Pos(1, 1));238 cm.execCommand("goDocStart");239 hasCursors(cm, 0, 0);240 select(cm, Pos(0, 1), Pos(1, 1));241 cm.execCommand("goDocEnd");242 hasCursors(cm, 1, 3);243 select(cm, Pos(0, 1), Pos(1, 1));244 cm.setExtending(true);245 cm.execCommand("goDocEnd");246 hasSelections(cm, 1, 1, 1, 3);247 }, {value: "abc\ndef"});248 testCM("selectionHistory", function(cm) {249 for (var i = 0; i < 3; ++i)250 cm.addSelection(Pos(0, i * 2), Pos(0, i * 2 + 1));251 cm.execCommand("undoSelection");252 eq(cm.getSelection(), "1\n2");253 cm.execCommand("undoSelection");254 eq(cm.getSelection(), "1");255 cm.execCommand("undoSelection");256 eq(cm.getSelection(), "");257 eqPos(cm.getCursor(), Pos(0, 0));258 cm.execCommand("redoSelection");259 eq(cm.getSelection(), "1");260 cm.execCommand("redoSelection");261 eq(cm.getSelection(), "1\n2");262 cm.execCommand("redoSelection");263 eq(cm.getSelection(), "1\n2\n3");264 }, {value: "1 2 3"});...

Full Screen

Full Screen

main.ts

Source:main.ts Github

copy

Full Screen

1(() => {2 const pos: NodeListOf<Element> = document.querySelectorAll('.row');3 let option: string = "O";4 pos.forEach(pos => pos.addEventListener("click", () => {5 CHECKoption();6 if (pos.innerHTML == "") {7 const x = document.createElement("h1");8 pos.appendChild(x); x.classList.add(`${option}-item`); x.innerHTML = option;9 };10 function CHECKoption() {11 if (option == "X") {12 option = "O";13 } else {14 option = "X";15 };16 };17 CHECKwin();18 }));19 function CHECKwin() {20 if (pos[0].innerHTML == pos[1].innerHTML && pos[2].innerHTML == pos[1].innerHTML && pos[0].innerHTML !== "" && pos[1].innerHTML !== "" && pos[2].innerHTML !== "") {21 win(0, 1, 2);22 }23 if (pos[3].innerHTML == pos[4].innerHTML && pos[5].innerHTML == pos[4].innerHTML && pos[3].innerHTML !== "" && pos[4].innerHTML !== "" && pos[5].innerHTML !== "") {24 win(3, 4, 5);25 }26 if (pos[6].innerHTML == pos[7].innerHTML && pos[8].innerHTML == pos[7].innerHTML && pos[6].innerHTML !== "" && pos[7].innerHTML !== "" && pos[8].innerHTML !== "") {27 win(6, 7, 8)28 }29 if (pos[0].innerHTML == pos[3].innerHTML && pos[6].innerHTML == pos[3].innerHTML && pos[0].innerHTML !== "" && pos[3].innerHTML !== "" && pos[6].innerHTML !== "") {30 win(0, 3, 6)31 }32 // ////33 if (pos[1].innerHTML == pos[4].innerHTML && pos[7].innerHTML == pos[4].innerHTML && pos[1].innerHTML !== "" && pos[4].innerHTML !== "" && pos[7].innerHTML !== "") {34 win(1, 4, 7)35 }36 if (pos[2].innerHTML == pos[5].innerHTML && pos[8].innerHTML == pos[5].innerHTML && pos[2].innerHTML !== "" && pos[5].innerHTML !== "" && pos[8].innerHTML !== "") {37 win(2, 5, 8)38 }39 if (pos[0].innerHTML == pos[4].innerHTML && pos[8].innerHTML == pos[4].innerHTML && pos[0].innerHTML !== "" && pos[4].innerHTML !== "" && pos[8].innerHTML !== "") {40 win(0, 4, 8)41 }42 if (pos[2].innerHTML == pos[4].innerHTML && pos[6].innerHTML == pos[4].innerHTML && pos[2].innerHTML !== "" && pos[4].innerHTML !== "" && pos[6].innerHTML !== "") {43 win(2, 4, 6)44 }45 46 if (pos[0].innerHTML!==""&&pos[1].innerHTML!==""&&pos[2].innerHTML!==""&&pos[3].innerHTML!==""&&pos[4].innerHTML!==""&&pos[5].innerHTML!==""&&pos[6].innerHTML!==""&&pos[7].innerHTML!==""&&pos[8].innerHTML!=="") {47 alert("The end") 48 }49 }50 function win(x1: number, x2: number, x3: number) {51 pos[x1].classList.add("win");52 pos[x2].classList.add("win");53 pos[x3].classList.add("win");54 var winnerOption = pos[x3].childNodes[0].innerHTML;55 console.log(winnerOption);56 let x = document.createElement("div");57 let y = document.createElement("h1");58 let t = document.createElement("button");59 document.body.appendChild(x);60 x.classList.add("end");61 function whoWin(winnerOption: any) {62 y.innerHTML = `${winnerOption} Win :)`;63 }64 whoWin(winnerOption);65 t.addEventListener("click", reset);66 const end = <HTMLDivElement>document.querySelector('.end');67 end.appendChild(y);68 end.appendChild(t);69 function reset() {70 window.location.reload();71 }72 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { pos } = require('fast-check-monorepo');2console.log(pos(1, 2));3console.log(pos(1, -2));4console.log(pos(-1, 2));5console.log(pos(-1, -2));6const { pos } = require('fast-check-monorepo');7console.log(pos(1, 2));8console.log(pos(1, -2));9console.log(pos(-1, 2));10console.log(pos(-1, -2));11const { pos } = require('fast-check-monorepo');12console.log(pos(1, 2));13console.log(pos(1, -2));14console.log(pos(-1, 2));15console.log(pos(-1, -2));16const { pos } = require('fast-check-monorepo');17console.log(pos(1, 2));18console.log(pos(1, -2));19console.log(pos(-1, 2));20console.log(pos(-1, -2));21const { pos } = require('fast-check-monorepo');22console.log(pos(1, 2));23console.log(pos(1, -2));24console.log(pos(-1, 2));25console.log(pos(-1, -2));26const { pos } = require('fast-check-monorepo');27console.log(pos(1, 2));28console.log(pos(1, -2));29console.log(pos(-1, 2));30console.log(pos(-1, -2));31const { pos } = require('fast-check-monorepo');32console.log(pos(1, 2));33console.log(pos(1, -2));34console.log(pos(-1, 2));35console.log(pos(-1, -2));36const { pos } = require('fast-check-monorepo');

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { pos } = require('fast-check-monorepo');3fc.assert(4 fc.property(pos(), (n) => {5 return n > 0;6 })7);8const fc = require('fast-check');9const { pos } = require('fast-check-monorepo');10fc.assert(11 fc.property(pos(), (n) => {12 return n > 0;13 })14);15const fc = require('fast-check');16const { pos } = require('fast-check-monorepo');17fc.assert(18 fc.property(pos(), (n) => {19 return n > 0;20 })21);22const fc = require('fast-check');23const { pos } = require('fast-check-monorepo');24fc.assert(25 fc.property(pos(), (n) => {26 return n > 0;27 })28);29const fc = require('fast-check');30const { pos } = require('fast-check-monorepo');31fc.assert(32 fc.property(pos(), (n) => {33 return n > 0;34 })35);36const fc = require('fast-check');37const { pos } = require('fast-check-monorepo');38fc.assert(39 fc.property(pos(), (n) => {40 return n > 0;41 })42);43const fc = require('fast-check');44const { pos } = require('fast-check-monorepo');45fc.assert(46 fc.property(pos(), (n) => {47 return n > 0;48 })49);50const fc = require('fast-check');51const { pos } = require('fast-check-monorepo');52fc.assert(53 fc.property(pos(), (n) => {54 return n > 0;55 })56);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { pos } from "fast-check-monorepo";2const a = pos();3console.log(a);4import { pos } from "fast-check-monorepo";5const a = pos();6console.log(a);7import { pos } from "fast-check-monorepo";8const a = pos();9console.log(a);10import { pos } from "fast-check-monorepo";11const a = pos();12console.log(a);13import { pos } from "fast-check-monorepo";14const a = pos();15console.log(a);16import { pos } from "fast-check-monorepo";17const a = pos();18console.log(a);19import { pos } from "fast-check-monorepo";20const a = pos();21console.log(a);22import { pos } from "fast-check-monorepo";23const a = pos();24console.log(a);25import { pos } from "fast-check-monorepo";26const a = pos();27console.log(a);28import { pos } from "fast-check-monorepo";29const a = pos();30console.log(a);31import { pos } from "fast-check-monorepo";32const a = pos();33console.log(a);34import { pos } from "fast-check-monorepo";35const a = pos();36console.log(a);37import { pos } from "

Full Screen

Using AI Code Generation

copy

Full Screen

1const pos = require('fast-check-monorepo').pos;2const fc = require('fast-check');3fc.assert(fc.property(pos(), (p) => {4 return p >= 0;5}));6const pos = require('fast-check-monorepo').pos;7const fc = require('fast-check');8fc.assert(fc.property(pos(), (p) => {9 return p >= 0;10}));11const pos = require('fast-check-monorepo').pos;12const fc = require('fast-check');13fc.assert(fc.property(pos(), (p) => {14 return p >= 0;15}));16const pos = require('fast-check-monorepo').pos;17const fc = require('fast-check');18fc.assert(fc.property(pos(), (p) => {19 return p >= 0;20}));21const pos = require('fast-check-monorepo').pos;22const fc = require('fast-check');23fc.assert(fc.property(pos(), (p) => {24 return p >= 0;25}));26const pos = require('fast-check-monorepo').pos;27const fc = require('fast-check');28fc.assert(fc.property(pos(), (p) => {29 return p >= 0;30}));31const pos = require('fast-check-monorepo').pos;32const fc = require('fast-check');33fc.assert(fc.property(pos(), (p) => {34 return p >= 0;35}));36const pos = require('fast-check-monorepo').pos;37const fc = require('fast-check');38fc.assert(fc.property(pos(), (p) => {39 return p >= 0;40}));41const pos = require('fast-check-monorepo').pos;42const fc = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const pos = require('fast-check-monorepo').pos;3fc.assert(fc.property(pos, n => n > 0))4const fc = require('fast-check');5const pos = require('fast-check-monorepo').pos;6fc.assert(fc.property(pos, n => n > 0))7test('test', async () => {8 const result = await myFunction();9 expect(result).toBe('test');10});11test('test', async () => {12 try {13 await myFunction();14 } catch (e) {15 expect(e).toBeDefined();16 }17});18test('test', async () => {19 try {20 await myFunction();21 } catch (e) {22 expect(e).toBeDefined();23 }24 expect(true).toBe(true);25});26I don't want to add expect(true).toBe(true) to all of my tests that check if a promise is rejected. Is there a way to fix this error? Or is there a better way to test that a promise is rejected?27test('test

Full Screen

Using AI Code Generation

copy

Full Screen

1const { pos } = require('fast-check-monorepo')2const { assert } = require('chai')3describe('pos', () => {4 it('should generate positive numbers', () => {5 const posNumbers = pos().generate(mrng => mrng.nextInt())6 assert(posNumbers.every(n => n >= 0))7 })8})9const { pos } = require('fast-check-monorepo')10const { assert } = require('chai')11describe('pos', () => {12 it('should generate positive numbers', () => {13 const posNumbers = pos().generate(mrng => mrng.nextInt())14 assert(posNumbers.every(n => n >= 0))15 })16})17const { pos } = require('fast-check-monorepo')18const { assert } = require('chai')19describe('pos', () => {20 it('should generate positive numbers', () => {21 const posNumbers = pos().generate(mrng => mrng.nextInt())22 assert(posNumbers.every(n => n >= 0))23 })24})25const { pos } = require('fast-check-monorepo')26const { assert } = require('chai')27describe('pos', () => {28 it('should generate positive numbers', () => {29 const posNumbers = pos().generate(mrng => mrng.nextInt())30 assert(posNumbers.every(n => n >= 0))31 })32})33const { pos } = require('fast-check-monorepo')34const { assert } = require('chai')35describe('pos', () => {36 it('should generate positive numbers', () => {37 const posNumbers = pos().generate(mrng => mrng.nextInt())38 assert(posNumbers.every(n => n >= 0))39 })40})41const { pos } = require('fast-check-monorepo')42const { assert } = require('chai')43describe('pos', () => {44 it('should generate positive numbers', () => {45 const posNumbers = pos().generate

Full Screen

Using AI Code Generation

copy

Full Screen

1const { pos } = require('fast-check-monorepo');2const { check } = require('fast-check');3const isEven = (n) => n % 2 === 0;4const { pos } = require('fast-check');5const { check } = require('fast-check');6const isEven = (n) => n % 2 === 0;7const { check } = require('fast-check-monorepo');8const isEven = (n) => n % 2 === 0;

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const { pos } = require("fast-check-monorepo");3const gen = fc.integer({ min: 0, max: 100 });4const gen2 = pos();5console.log(gen.sample());6console.log(gen2.sample());7const fc = require("fast-check");8const { pos } = require("fast-check-monorepo");9const gen = fc.integer({ min: 0, max: 100 });10const gen2 = pos();11const isPositive = (n) => n > 0;12fc.assert(13 fc.property(gen, (n) => isPositive(n)),14 { verbose: true }15);16fc.assert(17 fc.property(gen2, (n) => isPositive(n)),18 { verbose: true }19);20Property failed after 1 tests (1 shrinks) with:21Property failed after 1 tests (1 shrinks) with:22const fc = require("fast-check");23const { pos } = require("fast-check-monorepo");24const gen = fc.integer({ min: 0, max: 100 });25const gen2 = pos();26const isPositive = (n) => n > 0;27fc.assert(28 fc.property(gen, (n) => is

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2describe('pos', () => {3 it('should return -1 if no vowel is found', () => {4 fc.assert(5 fc.property(fc.string(), str => {6 const pos = pos(str);7 expect(pos).toBe(-1);8 })9 );10 });11});12const fc = require('fast-check');13describe('pos', () => {14 it('should return the position of the first vowel', () => {15 fc.assert(16 fc.property(fc.string(), str => {17 const pos = pos(str);18 expect(pos).toBe(0);19 })20 );21 });22});23const fc = require('fast-check');24describe('pos', () => {25 it('should return the position of the first vowel', () => {26 fc.assert(27 fc.property(fc.string(), str => {28 const pos = pos(str);29 expect(pos).toBe(1);30 })31 );32 });33});34const fc = require('fast-check');35describe('

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful