test.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. (function() {
  2. var mode = CodeMirror.getMode({indentUnit: 2}, "css");
  3. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  4. // Error, because "foobarhello" is neither a known type or property, but
  5. // property was expected (after "and"), and it should be in parenthese.
  6. MT("atMediaUnknownType",
  7. "[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
  8. // Soft error, because "foobarhello" is not a known property or type.
  9. MT("atMediaUnknownProperty",
  10. "[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");
  11. // Make sure nesting works with media queries
  12. MT("atMediaMaxWidthNested",
  13. "[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
  14. MT("tagSelector",
  15. "[tag foo] { }");
  16. MT("classSelector",
  17. "[qualifier .foo-bar_hello] { }");
  18. MT("idSelector",
  19. "[builtin #foo] { [error #foo] }");
  20. MT("tagSelectorUnclosed",
  21. "[tag foo] { [property margin]: [number 0] } [tag bar] { }");
  22. MT("tagStringNoQuotes",
  23. "[tag foo] { [property font-family]: [variable hello] [variable world]; }");
  24. MT("tagStringDouble",
  25. "[tag foo] { [property font-family]: [string \"hello world\"]; }");
  26. MT("tagStringSingle",
  27. "[tag foo] { [property font-family]: [string 'hello world']; }");
  28. MT("tagColorKeyword",
  29. "[tag foo] {",
  30. " [property color]: [keyword black];",
  31. " [property color]: [keyword navy];",
  32. " [property color]: [keyword yellow];",
  33. "}");
  34. MT("tagColorHex3",
  35. "[tag foo] { [property background]: [atom #fff]; }");
  36. MT("tagColorHex6",
  37. "[tag foo] { [property background]: [atom #ffffff]; }");
  38. MT("tagColorHex4",
  39. "[tag foo] { [property background]: [atom&error #ffff]; }");
  40. MT("tagColorHexInvalid",
  41. "[tag foo] { [property background]: [atom&error #ffg]; }");
  42. MT("tagNegativeNumber",
  43. "[tag foo] { [property margin]: [number -5px]; }");
  44. MT("tagPositiveNumber",
  45. "[tag foo] { [property padding]: [number 5px]; }");
  46. MT("tagVendor",
  47. "[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");
  48. MT("tagBogusProperty",
  49. "[tag foo] { [property&error barhelloworld]: [number 0]; }");
  50. MT("tagTwoProperties",
  51. "[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
  52. MT("tagTwoPropertiesURL",
  53. "[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
  54. MT("commentSGML",
  55. "[comment <!--comment-->]");
  56. MT("commentSGML2",
  57. "[comment <!--comment]",
  58. "[comment -->] [tag div] {}");
  59. MT("indent_tagSelector",
  60. "[tag strong], [tag em] {",
  61. " [property background]: [atom rgba](",
  62. " [number 255], [number 255], [number 0], [number .2]",
  63. " );",
  64. "}");
  65. MT("indent_atMedia",
  66. "[def @media] {",
  67. " [tag foo] {",
  68. " [property color]:",
  69. " [keyword yellow];",
  70. " }",
  71. "}");
  72. MT("indent_comma",
  73. "[tag foo] {",
  74. " [property font-family]: [variable verdana],",
  75. " [atom sans-serif];",
  76. "}");
  77. MT("indent_parentheses",
  78. "[tag foo]:[variable-3 before] {",
  79. " [property background]: [atom url](",
  80. "[string blahblah]",
  81. "[string etc]",
  82. "[string ]) [keyword !important];",
  83. "}");
  84. MT("font_face",
  85. "[def @font-face] {",
  86. " [property font-family]: [string 'myfont'];",
  87. " [error nonsense]: [string 'abc'];",
  88. " [property src]: [atom url]([string http://blah]),",
  89. " [atom url]([string http://foo]);",
  90. "}");
  91. })();