noHighlight.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 'use strict';
  2. let _ = require('lodash');
  3. describe('no highlighting', function() {
  4. before(function() {
  5. const testHTML = document.querySelectorAll('#no-highlight pre');
  6. this.blocks = _.map(testHTML, 'children[0].innerHTML');
  7. this.expected = {
  8. html: '<div id="contents">\n ' +
  9. '<p>Hello, World!\n</div>',
  10. python: 'for x in [1, 2, 3]: count(x)',
  11. javascript: '<span class="hljs-keyword">var</span> x = ' +
  12. '<span class="hljs-string">\'foo\'</span>;'
  13. };
  14. });
  15. it('should keep block unchanged (nohighlight)', function() {
  16. const expected = this.expected.html,
  17. actual = this.blocks[0];
  18. actual.should.equal(expected);
  19. });
  20. it('should keep block unchanged (no-highlight)', function() {
  21. const expected = this.expected.html,
  22. actual = this.blocks[1];
  23. actual.should.equal(expected);
  24. });
  25. it('should keep block unchanged (plain)', function() {
  26. const expected = this.expected.html,
  27. actual = this.blocks[2];
  28. actual.should.equal(expected);
  29. });
  30. it('should keep block unchanged (text)', function() {
  31. const expected = this.expected.html,
  32. actual = this.blocks[3];
  33. actual.should.equal(expected);
  34. });
  35. it('should skip pre tags without a child code tag', function() {
  36. const expected = 'Computer output',
  37. actual = this.blocks[4];
  38. actual.should.equal(expected);
  39. });
  40. it('should keep block unchanged (unsupported language)', function() {
  41. const expected = this.expected.python,
  42. actual = this.blocks[5];
  43. actual.should.equal(expected);
  44. });
  45. it('should keep block unchanged (unsupported lang)', function() {
  46. const expected = this.expected.python,
  47. actual = this.blocks[6];
  48. actual.should.equal(expected);
  49. });
  50. it('should keep block unchanged (unsupported prefixed language)', function() {
  51. const expected = this.expected.python,
  52. actual = this.blocks[7];
  53. actual.should.equal(expected);
  54. });
  55. it('should highlight class names containing text at the start', function() {
  56. const expected = this.expected.javascript,
  57. actual = this.blocks[8];
  58. actual.should.equal(expected);
  59. });
  60. it('should highlight class names containing text at the end', function() {
  61. const expected = this.expected.javascript,
  62. actual = this.blocks[9];
  63. actual.should.equal(expected);
  64. });
  65. });