index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use strict';
  2. let _ = require('lodash');
  3. let bluebird = require('bluebird');
  4. let hljs = require('../../build');
  5. let jsdomEnv = bluebird.promisify(require('jsdom').env);
  6. let readFile = bluebird.promisify(require('fs').readFile);
  7. let utility = require('../utility');
  8. describe('special cases tests', function() {
  9. before(function() {
  10. const filename = utility.buildPath('fixtures', 'index.html');
  11. return readFile(filename, 'utf-8')
  12. .then(page => jsdomEnv(page))
  13. .then(window => {
  14. let blocks;
  15. // Allows hljs to use document
  16. global.document = window.document;
  17. // Special language to test endsWithParentVariants
  18. hljs.registerLanguage('nested', require('../fixtures/nested.js'));
  19. // Setup hljs environment
  20. hljs.configure({ tabReplace: ' ' });
  21. hljs.initHighlighting();
  22. // Setup hljs for non-`<pre><code>` tests
  23. hljs.configure({ useBR: true });
  24. blocks = document.querySelectorAll('.code');
  25. _.each(blocks, hljs.highlightBlock);
  26. });
  27. });
  28. require('./explicitLanguage');
  29. require('./customMarkup');
  30. require('./languageAlias');
  31. require('./noHighlight');
  32. require('./subLanguages');
  33. require('./buildClassName');
  34. require('./useBr');
  35. require('./endsWithParentVariants')
  36. });