github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/app/public/codemirror/mode/css/test.js (about)

     1  // CodeMirror, copyright (c) by Marijn Haverbeke and others
     2  // Distributed under an MIT license: http://codemirror.net/LICENSE
     3  
     4  (function() {
     5    var mode = CodeMirror.getMode({indentUnit: 2}, "css");
     6    function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
     7  
     8    // Error, because "foobarhello" is neither a known type or property, but
     9    // property was expected (after "and"), and it should be in parentheses.
    10    MT("atMediaUnknownType",
    11       "[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
    12  
    13    // Soft error, because "foobarhello" is not a known property or type.
    14    MT("atMediaUnknownProperty",
    15       "[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");
    16  
    17    // Make sure nesting works with media queries
    18    MT("atMediaMaxWidthNested",
    19       "[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
    20  
    21    MT("atMediaFeatureValueKeyword",
    22       "[def @media] ([property orientation]: [keyword landscape]) { }");
    23  
    24    MT("atMediaUnknownFeatureValueKeyword",
    25       "[def @media] ([property orientation]: [error upsidedown]) { }");
    26  
    27    MT("tagSelector",
    28       "[tag foo] { }");
    29  
    30    MT("classSelector",
    31       "[qualifier .foo-bar_hello] { }");
    32  
    33    MT("idSelector",
    34       "[builtin #foo] { [error #foo] }");
    35  
    36    MT("tagSelectorUnclosed",
    37       "[tag foo] { [property margin]: [number 0] } [tag bar] { }");
    38  
    39    MT("tagStringNoQuotes",
    40       "[tag foo] { [property font-family]: [variable hello] [variable world]; }");
    41  
    42    MT("tagStringDouble",
    43       "[tag foo] { [property font-family]: [string \"hello world\"]; }");
    44  
    45    MT("tagStringSingle",
    46       "[tag foo] { [property font-family]: [string 'hello world']; }");
    47  
    48    MT("tagColorKeyword",
    49       "[tag foo] {",
    50       "  [property color]: [keyword black];",
    51       "  [property color]: [keyword navy];",
    52       "  [property color]: [keyword yellow];",
    53       "}");
    54  
    55    MT("tagColorHex3",
    56       "[tag foo] { [property background]: [atom #fff]; }");
    57  
    58    MT("tagColorHex4",
    59       "[tag foo] { [property background]: [atom #ffff]; }");
    60  
    61    MT("tagColorHex6",
    62       "[tag foo] { [property background]: [atom #ffffff]; }");
    63  
    64    MT("tagColorHex8",
    65       "[tag foo] { [property background]: [atom #ffffffff]; }");
    66  
    67    MT("tagColorHex5Invalid",
    68       "[tag foo] { [property background]: [atom&error #fffff]; }");
    69  
    70    MT("tagColorHexInvalid",
    71       "[tag foo] { [property background]: [atom&error #ffg]; }");
    72  
    73    MT("tagNegativeNumber",
    74       "[tag foo] { [property margin]: [number -5px]; }");
    75  
    76    MT("tagPositiveNumber",
    77       "[tag foo] { [property padding]: [number 5px]; }");
    78  
    79    MT("tagVendor",
    80       "[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");
    81  
    82    MT("tagBogusProperty",
    83       "[tag foo] { [property&error barhelloworld]: [number 0]; }");
    84  
    85    MT("tagTwoProperties",
    86       "[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
    87  
    88    MT("tagTwoPropertiesURL",
    89       "[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
    90  
    91    MT("indent_tagSelector",
    92       "[tag strong], [tag em] {",
    93       "  [property background]: [atom rgba](",
    94       "    [number 255], [number 255], [number 0], [number .2]",
    95       "  );",
    96       "}");
    97  
    98    MT("indent_atMedia",
    99       "[def @media] {",
   100       "  [tag foo] {",
   101       "    [property color]:",
   102       "      [keyword yellow];",
   103       "  }",
   104       "}");
   105  
   106    MT("indent_comma",
   107       "[tag foo] {",
   108       "  [property font-family]: [variable verdana],",
   109       "    [atom sans-serif];",
   110       "}");
   111  
   112    MT("indent_parentheses",
   113       "[tag foo]:[variable-3 before] {",
   114       "  [property background]: [atom url](",
   115       "[string     blahblah]",
   116       "[string     etc]",
   117       "[string   ]) [keyword !important];",
   118       "}");
   119  
   120    MT("font_face",
   121       "[def @font-face] {",
   122       "  [property font-family]: [string 'myfont'];",
   123       "  [error nonsense]: [string 'abc'];",
   124       "  [property src]: [atom url]([string http://blah]),",
   125       "    [atom url]([string http://foo]);",
   126       "}");
   127  
   128    MT("empty_url",
   129       "[def @import] [atom url]() [attribute screen];");
   130  
   131    MT("parens",
   132       "[qualifier .foo] {",
   133       "  [property background-image]: [variable fade]([atom #000], [number 20%]);",
   134       "  [property border-image]: [atom linear-gradient](",
   135       "    [atom to] [atom bottom],",
   136       "    [variable fade]([atom #000], [number 20%]) [number 0%],",
   137       "    [variable fade]([atom #000], [number 20%]) [number 100%]",
   138       "  );",
   139       "}");
   140  
   141    MT("css_variable",
   142       ":[variable-3 root] {",
   143       "  [variable-2 --main-color]: [atom #06c];",
   144       "}",
   145       "[tag h1][builtin #foo] {",
   146       "  [property color]: [atom var]([variable-2 --main-color]);",
   147       "}");
   148  
   149    MT("supports",
   150       "[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {",
   151       "  [property text-align-last]: [atom justify];",
   152       "}");
   153  
   154     MT("document",
   155        "[def @document] [tag url]([string http://blah]),",
   156        "  [tag url-prefix]([string https://]),",
   157        "  [tag domain]([string blah.com]),",
   158        "  [tag regexp]([string \".*blah.+\"]) {",
   159        "    [builtin #id] {",
   160        "      [property background-color]: [keyword white];",
   161        "    }",
   162        "    [tag foo] {",
   163        "      [property font-family]: [variable Verdana], [atom sans-serif];",
   164        "    }",
   165        "}");
   166  
   167     MT("document_url",
   168        "[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");
   169  
   170     MT("document_urlPrefix",
   171        "[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }");
   172  
   173     MT("document_domain",
   174        "[def @document] [tag domain]([string blah.com]) { [tag foo] { } }");
   175  
   176     MT("document_regexp",
   177        "[def @document] [tag regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
   178  
   179     MT("counter-style",
   180        "[def @counter-style] [variable binary] {",
   181        "  [property system]: [atom numeric];",
   182        "  [property symbols]: [number 0] [number 1];",
   183        "  [property suffix]: [string \".\"];",
   184        "  [property range]: [atom infinite];",
   185        "  [property speak-as]: [atom numeric];",
   186        "}");
   187  
   188     MT("counter-style-additive-symbols",
   189        "[def @counter-style] [variable simple-roman] {",
   190        "  [property system]: [atom additive];",
   191        "  [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];",
   192        "  [property range]: [number 1] [number 49];",
   193        "}");
   194  
   195     MT("counter-style-use",
   196        "[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");
   197  
   198     MT("counter-style-symbols",
   199        "[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
   200  })();