How to use testMode method in redwood

Best JavaScript code snippet using redwood

test.js

Source:test.js Github

copy

Full Screen

1// Initiate ModeTest and set defaults2var MT = ModeTest;3MT.modeName = 'markdown';4MT.modeOptions = {};5MT.testMode(6 'plainText',7 'foo',8 [9 null, 'foo'10 ]11);12// Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)13MT.testMode(14 'codeBlocksUsing4Spaces',15 ' foo',16 [17 null, ' ',18 'comment', 'foo'19 ]20);21// Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value)22MT.testMode(23 'codeBlocksUsing1Tab',24 '\tfoo',25 [26 null, '\t',27 'comment', 'foo'28 ]29);30// Inline code using backticks31MT.testMode(32 'inlineCodeUsingBackticks',33 'foo `bar`',34 [35 null, 'foo ',36 'comment', '`bar`'37 ]38);39// Unclosed backticks40// Instead of simply marking as CODE, it would be nice to have an 41// incomplete flag for CODE, that is styled slightly different.42MT.testMode(43 'unclosedBackticks',44 'foo `bar',45 [46 null, 'foo ',47 'comment', '`bar'48 ]49);50// Per documentation: "To include a literal backtick character within a 51// code span, you can use multiple backticks as the opening and closing 52// delimiters"53MT.testMode(54 'doubleBackticks',55 '``foo ` bar``',56 [57 'comment', '``foo ` bar``'58 ]59);60// Tests based on Dingus61// http://daringfireball.net/projects/markdown/dingus62// 63// Multiple backticks within an inline code block64MT.testMode(65 'consecutiveBackticks',66 '`foo```bar`',67 [68 'comment', '`foo```bar`'69 ]70);71// Multiple backticks within an inline code block with a second code block72MT.testMode(73 'consecutiveBackticks',74 '`foo```bar` hello `world`',75 [76 'comment', '`foo```bar`',77 null, ' hello ',78 'comment', '`world`'79 ]80);81// Unclosed with several different groups of backticks82MT.testMode(83 'unclosedBackticks',84 '``foo ``` bar` hello',85 [86 'comment', '``foo ``` bar` hello'87 ]88);89// Closed with several different groups of backticks90MT.testMode(91 'closedBackticks',92 '``foo ``` bar` hello`` world',93 [94 'comment', '``foo ``` bar` hello``',95 null, ' world'96 ]97);98// atx headers99// http://daringfireball.net/projects/markdown/syntax#header100// 101// H1102MT.testMode(103 'atxH1',104 '# foo',105 [106 'header', '# foo'107 ]108);109// H2110MT.testMode(111 'atxH2',112 '## foo',113 [114 'header', '## foo'115 ]116);117// H3118MT.testMode(119 'atxH3',120 '### foo',121 [122 'header', '### foo'123 ]124);125// H4126MT.testMode(127 'atxH4',128 '#### foo',129 [130 'header', '#### foo'131 ]132);133// H5134MT.testMode(135 'atxH5',136 '##### foo',137 [138 'header', '##### foo'139 ]140);141// H6142MT.testMode(143 'atxH6',144 '###### foo',145 [146 'header', '###### foo'147 ]148);149// H6 - 7x '#' should still be H6, per Dingus150// http://daringfireball.net/projects/markdown/dingus151MT.testMode(152 'atxH6NotH7',153 '####### foo',154 [155 'header', '####### foo'156 ]157);158// Setext headers - H1, H2159// Per documentation, "Any number of underlining =’s or -’s will work."160// http://daringfireball.net/projects/markdown/syntax#header161// Ideally, the text would be marked as `header` as well, but this is 162// not really feasible at the moment. So, instead, we're testing against 163// what works today, to avoid any regressions.164// 165// Check if single underlining = works166MT.testMode(167 'setextH1',168 'foo\n=',169 [170 null, 'foo',171 'header', '='172 ]173);174// Check if 3+ ='s work175MT.testMode(176 'setextH1',177 'foo\n===',178 [179 null, 'foo',180 'header', '==='181 ]182);183// Check if single underlining - works184MT.testMode(185 'setextH2',186 'foo\n-',187 [188 null, 'foo',189 'header', '-'190 ]191);192// Check if 3+ -'s work193MT.testMode(194 'setextH2',195 'foo\n---',196 [197 null, 'foo',198 'header', '---'199 ]200);201// Single-line blockquote with trailing space202MT.testMode(203 'blockquoteSpace',204 '> foo',205 [206 'quote', '> foo'207 ]208);209// Single-line blockquote210MT.testMode(211 'blockquoteNoSpace',212 '>foo',213 [214 'quote', '>foo'215 ]216);217// Single-line blockquote followed by normal paragraph218MT.testMode(219 'blockquoteThenParagraph',220 '>foo\n\nbar',221 [222 'quote', '>foo',223 null, 'bar'224 ]225);226// Multi-line blockquote (lazy mode)227MT.testMode(228 'multiBlockquoteLazy',229 '>foo\nbar',230 [231 'quote', '>foo',232 'quote', 'bar'233 ]234);235// Multi-line blockquote followed by normal paragraph (lazy mode)236MT.testMode(237 'multiBlockquoteLazyThenParagraph',238 '>foo\nbar\n\nhello',239 [240 'quote', '>foo',241 'quote', 'bar',242 null, 'hello'243 ]244);245// Multi-line blockquote (non-lazy mode)246MT.testMode(247 'multiBlockquote',248 '>foo\n>bar',249 [250 'quote', '>foo',251 'quote', '>bar'252 ]253);254// Multi-line blockquote followed by normal paragraph (non-lazy mode)255MT.testMode(256 'multiBlockquoteThenParagraph',257 '>foo\n>bar\n\nhello',258 [259 'quote', '>foo',260 'quote', '>bar',261 null, 'hello'262 ]263);264// Check list types265MT.testMode(266 'listAsterisk',267 '* foo\n* bar',268 [269 'string', '* foo',270 'string', '* bar'271 ]272);273MT.testMode(274 'listPlus',275 '+ foo\n+ bar',276 [277 'string', '+ foo',278 'string', '+ bar'279 ]280);281MT.testMode(282 'listDash',283 '- foo\n- bar',284 [285 'string', '- foo',286 'string', '- bar'287 ]288);289MT.testMode(290 'listNumber',291 '1. foo\n2. bar',292 [293 'string', '1. foo',294 'string', '2. bar'295 ]296);297// Formatting in lists (*)298MT.testMode(299 'listAsteriskFormatting',300 '* *foo* bar\n\n* **foo** bar\n\n* ***foo*** bar\n\n* `foo` bar',301 [302 'string', '* ',303 'string em', '*foo*',304 'string', ' bar',305 'string', '* ',306 'string strong', '**foo**',307 'string', ' bar',308 'string', '* ',309 'string strong', '**',310 'string emstrong', '*foo**',311 'string em', '*',312 'string', ' bar',313 'string', '* ',314 'string comment', '`foo`',315 'string', ' bar'316 ]317);318// Formatting in lists (+)319MT.testMode(320 'listPlusFormatting',321 '+ *foo* bar\n\n+ **foo** bar\n\n+ ***foo*** bar\n\n+ `foo` bar',322 [323 'string', '+ ',324 'string em', '*foo*',325 'string', ' bar',326 'string', '+ ',327 'string strong', '**foo**',328 'string', ' bar',329 'string', '+ ',330 'string strong', '**',331 'string emstrong', '*foo**',332 'string em', '*',333 'string', ' bar',334 'string', '+ ',335 'string comment', '`foo`',336 'string', ' bar'337 ]338);339// Formatting in lists (-)340MT.testMode(341 'listDashFormatting',342 '- *foo* bar\n\n- **foo** bar\n\n- ***foo*** bar\n\n- `foo` bar',343 [344 'string', '- ',345 'string em', '*foo*',346 'string', ' bar',347 'string', '- ',348 'string strong', '**foo**',349 'string', ' bar',350 'string', '- ',351 'string strong', '**',352 'string emstrong', '*foo**',353 'string em', '*',354 'string', ' bar',355 'string', '- ',356 'string comment', '`foo`',357 'string', ' bar'358 ]359);360// Formatting in lists (1.)361MT.testMode(362 'listNumberFormatting',363 '1. *foo* bar\n\n2. **foo** bar\n\n3. ***foo*** bar\n\n4. `foo` bar',364 [365 'string', '1. ',366 'string em', '*foo*',367 'string', ' bar',368 'string', '2. ',369 'string strong', '**foo**',370 'string', ' bar',371 'string', '3. ',372 'string strong', '**',373 'string emstrong', '*foo**',374 'string em', '*',375 'string', ' bar',376 'string', '4. ',377 'string comment', '`foo`',378 'string', ' bar'379 ]380);381// Paragraph lists382MT.testMode(383 'listParagraph',384 '* foo\n\n* bar',385 [386 'string', '* foo',387 'string', '* bar'388 ]389);390// Multi-paragraph lists391//392// 4 spaces393MT.testMode(394 'listMultiParagraph',395 '* foo\n\n* bar\n\n hello',396 [397 'string', '* foo',398 'string', '* bar',399 null, ' ',400 'string', 'hello'401 ]402);403// 4 spaces, extra blank lines (should still be list, per Dingus)404MT.testMode(405 'listMultiParagraphExtra',406 '* foo\n\n* bar\n\n\n hello',407 [408 'string', '* foo',409 'string', '* bar',410 null, ' ',411 'string', 'hello'412 ]413);414// 4 spaces, plus 1 space (should still be list, per Dingus)415MT.testMode(416 'listMultiParagraphExtraSpace',417 '* foo\n\n* bar\n\n hello\n\n world',418 [419 'string', '* foo',420 'string', '* bar',421 null, ' ',422 'string', 'hello',423 null, ' ',424 'string', 'world'425 ]426);427// 1 tab428MT.testMode(429 'listTab',430 '* foo\n\n* bar\n\n\thello',431 [432 'string', '* foo',433 'string', '* bar',434 null, '\t',435 'string', 'hello'436 ]437);438// No indent439MT.testMode(440 'listNoIndent',441 '* foo\n\n* bar\n\nhello',442 [443 'string', '* foo',444 'string', '* bar',445 null, 'hello'446 ]447);448// Blockquote449MT.testMode(450 'blockquote',451 '* foo\n\n* bar\n\n > hello',452 [453 'string', '* foo',454 'string', '* bar',455 null, ' ',456 'string quote', '> hello'457 ]458);459// Code block460MT.testMode(461 'blockquoteCode',462 '* foo\n\n* bar\n\n > hello\n\n world',463 [464 'string', '* foo',465 'string', '* bar',466 null, ' ',467 'comment', '> hello',468 null, ' ',469 'string', 'world'470 ]471);472// Code block followed by text473MT.testMode(474 'blockquoteCodeText',475 '* foo\n\n bar\n\n hello\n\n world',476 [477 'string', '* foo',478 null, ' ',479 'string', 'bar',480 null, ' ',481 'comment', 'hello',482 null, ' ',483 'string', 'world'484 ]485);486// Nested list487// 488// *489MT.testMode(490 'listAsteriskNested',491 '* foo\n\n * bar',492 [493 'string', '* foo',494 null, ' ',495 'string', '* bar'496 ]497);498// +499MT.testMode(500 'listPlusNested',501 '+ foo\n\n + bar',502 [503 'string', '+ foo',504 null, ' ',505 'string', '+ bar'506 ]507);508// -509MT.testMode(510 'listDashNested',511 '- foo\n\n - bar',512 [513 'string', '- foo',514 null, ' ',515 'string', '- bar'516 ]517);518// 1.519MT.testMode(520 'listNumberNested',521 '1. foo\n\n 2. bar',522 [523 'string', '1. foo',524 null, ' ',525 'string', '2. bar'526 ]527);528// Mixed529MT.testMode(530 'listMixed',531 '* foo\n\n + bar\n\n - hello\n\n 1. world',532 [533 'string', '* foo',534 null, ' ',535 'string', '+ bar',536 null, ' ',537 'string', '- hello',538 null, ' ',539 'string', '1. world'540 ]541);542// Blockquote543MT.testMode(544 'listBlockquote',545 '* foo\n\n + bar\n\n > hello',546 [547 'string', '* foo',548 null, ' ',549 'string', '+ bar',550 null, ' ',551 'quote string', '> hello'552 ]553);554// Code555MT.testMode(556 'listCode',557 '* foo\n\n + bar\n\n hello',558 [559 'string', '* foo',560 null, ' ',561 'string', '+ bar',562 null, ' ',563 'comment', 'hello'564 ]565);566// Code followed by text567MT.testMode(568 'listCodeText',569 '* foo\n\n bar\n\nhello',570 [571 'string', '* foo',572 null, ' ',573 'comment', 'bar',574 null, 'hello'575 ]576);577// Following tests directly from official Markdown documentation578// http://daringfireball.net/projects/markdown/syntax#hr579MT.testMode(580 'hrSpace',581 '* * *',582 [583 'hr', '* * *'584 ]585);586MT.testMode(587 'hr',588 '***',589 [590 'hr', '***'591 ]592);593MT.testMode(594 'hrLong',595 '*****',596 [597 'hr', '*****'598 ]599);600MT.testMode(601 'hrSpaceDash',602 '- - -',603 [604 'hr', '- - -'605 ]606);607MT.testMode(608 'hrDashLong',609 '---------------------------------------',610 [611 'hr', '---------------------------------------'612 ]613);614// Inline link with title615MT.testMode(616 'linkTitle',617 '[foo](http://example.com/ "bar") hello',618 [619 'link', '[foo]',620 'string', '(http://example.com/ "bar")',621 null, ' hello'622 ]623);624// Inline link without title625MT.testMode(626 'linkNoTitle',627 '[foo](http://example.com/) bar',628 [629 'link', '[foo]',630 'string', '(http://example.com/)',631 null, ' bar'632 ]633);634// Reference-style links635MT.testMode(636 'linkReference',637 '[foo][bar] hello',638 [639 'link', '[foo]',640 'string', '[bar]',641 null, ' hello'642 ]643);644// Reference-style links with optional space separator (per docuentation)645// "You can optionally use a space to separate the sets of brackets"646MT.testMode(647 'linkReferenceSpace',648 '[foo] [bar] hello',649 [650 'link', '[foo]',651 null, ' ',652 'string', '[bar]',653 null, ' hello'654 ]655);656// Should only allow a single space ("...use *a* space...")657MT.testMode(658 'linkReferenceDoubleSpace',659 '[foo] [bar] hello',660 [661 null, '[foo] [bar] hello'662 ]663);664// Reference-style links with implicit link name665MT.testMode(666 'linkImplicit',667 '[foo][] hello',668 [669 'link', '[foo]',670 'string', '[]',671 null, ' hello'672 ]673);674// @todo It would be nice if, at some point, the document was actually675// checked to see if the referenced link exists676// Link label, for reference-style links (taken from documentation)677//678// No title679MT.testMode(680 'labelNoTitle',681 '[foo]: http://example.com/',682 [683 'link', '[foo]:',684 null, ' ',685 'string', 'http://example.com/'686 ]687);688// Space in ID and title689MT.testMode(690 'labelSpaceTitle',691 '[foo bar]: http://example.com/ "hello"',692 [693 'link', '[foo bar]:',694 null, ' ',695 'string', 'http://example.com/ "hello"'696 ]697);698// Double title699MT.testMode(700 'labelDoubleTitle',701 '[foo bar]: http://example.com/ "hello" "world"',702 [703 'link', '[foo bar]:',704 null, ' ',705 'string', 'http://example.com/ "hello"',706 null, ' "world"'707 ]708);709// Double quotes around title710MT.testMode(711 'labelTitleDoubleQuotes',712 '[foo]: http://example.com/ "bar"',713 [714 'link', '[foo]:',715 null, ' ',716 'string', 'http://example.com/ "bar"'717 ]718);719// Single quotes around title720MT.testMode(721 'labelTitleSingleQuotes',722 '[foo]: http://example.com/ \'bar\'',723 [724 'link', '[foo]:',725 null, ' ',726 'string', 'http://example.com/ \'bar\''727 ]728);729// Parentheses around title730MT.testMode(731 'labelTitleParenthese',732 '[foo]: http://example.com/ (bar)',733 [734 'link', '[foo]:',735 null, ' ',736 'string', 'http://example.com/ (bar)'737 ]738);739// Invalid title740MT.testMode(741 'labelTitleInvalid',742 '[foo]: http://example.com/ bar',743 [744 'link', '[foo]:',745 null, ' ',746 'string', 'http://example.com/',747 null, ' bar'748 ]749);750// Angle brackets around URL751MT.testMode(752 'labelLinkAngleBrackets',753 '[foo]: <http://example.com/> "bar"',754 [755 'link', '[foo]:',756 null, ' ',757 'string', '<http://example.com/> "bar"'758 ]759);760// Title on next line per documentation (double quotes)761MT.testMode(762 'labelTitleNextDoubleQuotes',763 '[foo]: http://example.com/\n"bar" hello',764 [765 'link', '[foo]:',766 null, ' ',767 'string', 'http://example.com/',768 'string', '"bar"',769 null, ' hello'770 ]771);772// Title on next line per documentation (single quotes)773MT.testMode(774 'labelTitleNextSingleQuotes',775 '[foo]: http://example.com/\n\'bar\' hello',776 [777 'link', '[foo]:',778 null, ' ',779 'string', 'http://example.com/',780 'string', '\'bar\'',781 null, ' hello'782 ]783);784// Title on next line per documentation (parentheses)785MT.testMode(786 'labelTitleNextParenthese',787 '[foo]: http://example.com/\n(bar) hello',788 [789 'link', '[foo]:',790 null, ' ',791 'string', 'http://example.com/',792 'string', '(bar)',793 null, ' hello'794 ]795);796// Title on next line per documentation (mixed)797MT.testMode(798 'labelTitleNextMixed',799 '[foo]: http://example.com/\n(bar" hello',800 [801 'link', '[foo]:',802 null, ' ',803 'string', 'http://example.com/',804 null, '(bar" hello'805 ]806);807// Automatic links808MT.testMode(809 'linkWeb',810 '<http://example.com/> foo',811 [812 'link', '<http://example.com/>',813 null, ' foo'814 ]815);816// Automatic email links817MT.testMode(818 'linkEmail',819 '<user@example.com> foo',820 [821 'link', '<user@example.com>',822 null, ' foo'823 ]824);825// Single asterisk826MT.testMode(827 'emAsterisk',828 '*foo* bar',829 [830 'em', '*foo*',831 null, ' bar'832 ]833);834// Single underscore835MT.testMode(836 'emUnderscore',837 '_foo_ bar',838 [839 'em', '_foo_',840 null, ' bar'841 ]842);843// Emphasis characters within a word844MT.testMode(845 'emInWordAsterisk',846 'foo*bar*hello',847 [848 null, 'foo',849 'em', '*bar*',850 null, 'hello'851 ]852);853MT.testMode(854 'emInWordUnderscore',855 'foo_bar_hello',856 [857 null, 'foo',858 'em', '_bar_',859 null, 'hello'860 ]861);862// Per documentation: "...surround an * or _ with spaces, it’ll be 863// treated as a literal asterisk or underscore."864// 865// Inside EM866MT.testMode(867 'emEscapedBySpaceIn',868 'foo _bar _ hello_ world',869 [870 null, 'foo ',871 'em', '_bar _ hello_',872 null, ' world'873 ]874);875// Outside EM876MT.testMode(877 'emEscapedBySpaceOut',878 'foo _ bar_hello_world',879 [880 null, 'foo _ bar',881 'em', '_hello_',882 null, 'world'883 ]884);885// Unclosed emphasis characters886// Instead of simply marking as EM / STRONG, it would be nice to have an 887// incomplete flag for EM and STRONG, that is styled slightly different.888MT.testMode(889 'emIncompleteAsterisk',890 'foo *bar',891 [892 null, 'foo ',893 'em', '*bar'894 ]895);896MT.testMode(897 'emIncompleteUnderscore',898 'foo _bar',899 [900 null, 'foo ',901 'em', '_bar'902 ]903);904// Double asterisk905MT.testMode(906 'strongAsterisk',907 '**foo** bar',908 [909 'strong', '**foo**',910 null, ' bar'911 ]912);913// Double underscore914MT.testMode(915 'strongUnderscore',916 '__foo__ bar',917 [918 'strong', '__foo__',919 null, ' bar'920 ]921);922// Triple asterisk923MT.testMode(924 'emStrongAsterisk',925 '*foo**bar*hello** world',926 [927 'em', '*foo',928 'emstrong', '**bar*',929 'strong', 'hello**',930 null, ' world'931 ]932);933// Triple underscore934MT.testMode(935 'emStrongUnderscore',936 '_foo__bar_hello__ world',937 [938 'em', '_foo',939 'emstrong', '__bar_',940 'strong', 'hello__',941 null, ' world'942 ]943);944// Triple mixed945// "...same character must be used to open and close an emphasis span.""946MT.testMode(947 'emStrongMixed',948 '_foo**bar*hello__ world',949 [950 'em', '_foo',951 'emstrong', '**bar*hello__ world'952 ]953);954MT.testMode(955 'emStrongMixed',956 '*foo__bar_hello** world',957 [958 'em', '*foo',959 'emstrong', '__bar_hello** world'960 ]961);962// These characters should be escaped:963// \ backslash964// ` backtick965// * asterisk966// _ underscore967// {} curly braces968// [] square brackets969// () parentheses970// # hash mark971// + plus sign972// - minus sign (hyphen)973// . dot974// ! exclamation mark975// 976// Backtick (code)977MT.testMode(978 'escapeBacktick',979 'foo \\`bar\\`',980 [981 null, 'foo \\`bar\\`'982 ]983);984MT.testMode(985 'doubleEscapeBacktick',986 'foo \\\\`bar\\\\`',987 [988 null, 'foo \\\\',989 'comment', '`bar\\\\`'990 ]991);992// Asterisk (em)993MT.testMode(994 'escapeAsterisk',995 'foo \\*bar\\*',996 [997 null, 'foo \\*bar\\*'998 ]999);1000MT.testMode(1001 'doubleEscapeAsterisk',1002 'foo \\\\*bar\\\\*',1003 [1004 null, 'foo \\\\',1005 'em', '*bar\\\\*'1006 ]1007);1008// Underscore (em)1009MT.testMode(1010 'escapeUnderscore',1011 'foo \\_bar\\_',1012 [1013 null, 'foo \\_bar\\_'1014 ]1015);1016MT.testMode(1017 'doubleEscapeUnderscore',1018 'foo \\\\_bar\\\\_',1019 [1020 null, 'foo \\\\',1021 'em', '_bar\\\\_'1022 ]1023);1024// Hash mark (headers)1025MT.testMode(1026 'escapeHash',1027 '\\# foo',1028 [1029 null, '\\# foo'1030 ]1031);1032MT.testMode(1033 'doubleEscapeHash',1034 '\\\\# foo',1035 [1036 null, '\\\\# foo'1037 ]...

Full Screen

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 redwood 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