nesting.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. var _helpers = require("./util/helpers");
  3. (0, _helpers.test)('nesting selector', '&', function (t, tree) {
  4. t.deepEqual(tree.nodes[0].nodes[0].value, '&');
  5. t.deepEqual(tree.nodes[0].nodes[0].type, 'nesting');
  6. });
  7. (0, _helpers.test)('nesting selector followed by a class', '& .class', function (t, tree) {
  8. t.deepEqual(tree.nodes[0].nodes[0].value, '&');
  9. t.deepEqual(tree.nodes[0].nodes[0].type, 'nesting');
  10. t.deepEqual(tree.nodes[0].nodes[1].value, ' ');
  11. t.deepEqual(tree.nodes[0].nodes[1].type, 'combinator');
  12. t.deepEqual(tree.nodes[0].nodes[2].value, 'class');
  13. t.deepEqual(tree.nodes[0].nodes[2].type, 'class');
  14. });
  15. (0, _helpers.test)('&foo', '&foo', function (t, tree) {
  16. t.deepEqual(tree.nodes[0].nodes[0].value, '&');
  17. t.deepEqual(tree.nodes[0].nodes[0].type, 'nesting');
  18. t.deepEqual(tree.nodes[0].nodes[1].value, 'foo');
  19. t.deepEqual(tree.nodes[0].nodes[1].type, 'tag');
  20. });
  21. (0, _helpers.test)('&-foo', '&-foo', function (t, tree) {
  22. t.deepEqual(tree.nodes[0].nodes[0].value, '&');
  23. t.deepEqual(tree.nodes[0].nodes[0].type, 'nesting');
  24. t.deepEqual(tree.nodes[0].nodes[1].value, '-foo');
  25. t.deepEqual(tree.nodes[0].nodes[1].type, 'tag');
  26. });
  27. (0, _helpers.test)('&_foo', '&_foo', function (t, tree) {
  28. t.deepEqual(tree.nodes[0].nodes[0].value, '&');
  29. t.deepEqual(tree.nodes[0].nodes[0].type, 'nesting');
  30. t.deepEqual(tree.nodes[0].nodes[1].value, '_foo');
  31. t.deepEqual(tree.nodes[0].nodes[1].type, 'tag');
  32. });
  33. (0, _helpers.test)('&|foo', '&|foo', function (t, tree) {
  34. var element = tree.nodes[0].nodes[0];
  35. t.deepEqual(element.value, 'foo');
  36. t.deepEqual(element.type, 'tag');
  37. t.deepEqual(element.namespace, '&');
  38. });