'use strict';

var _       = require('lodash');
var fs      = require('fs');
var hljs    = require('../../build');
var jsdom   = require('jsdom').jsdom;
var utility = require('../utility');

describe('special cases tests', function() {
  before(function(done) {
    var filename = utility.buildPath('fixtures', 'index.html');

    fs.readFile(filename, 'utf-8', function(err, page) {
      var blocks;

      // Allows hljs to use document
      global.document = jsdom(page);

      // Setup hljs environment
      hljs.configure({ tabReplace: '    ' });
      hljs.initHighlighting();

      // Setup hljs for non-`<pre><code>` tests
      hljs.configure({ useBR: true });

      blocks = document.querySelectorAll('.code');
      _.each(blocks, hljs.highlightBlock);

      done(err);
    });
  });

  require('./explicitLanguage');
  require('./customMarkup');
  require('./languageAlias');
  require('./noHighlight');
  require('./subLanguages');
  require('./buildClassName');
  require('./useBr');
});

@@ -16,24 +16,25 @@
 var _       
+ 
 = require('l
@@ -50,15 +50,16 @@
 var 
-fs     
+bluebird
  = r
@@ -66,18 +66,24 @@
 equire('
-fs
+bluebird
 ');%0Avar 
@@ -86,24 +86,25 @@
 var hljs    
+ 
 = require('.
@@ -130,35 +130,113 @@
 sdom
-   = require('jsdom').jsdom
+Env = bluebird.promisify(require('jsdom').env);%0Avar readFile = bluebird.promisify(require('fs').readFile)
 ;%0Ava
@@ -245,16 +245,17 @@
 utility 
+ 
 = requir
@@ -335,20 +335,16 @@
 unction(
-done
 ) %7B%0A    
@@ -412,11 +412,15 @@
     
-fs.
+return 
 read
@@ -445,29 +445,67 @@
 f-8'
-, function(err, page)
+)%0A      .then(page =%3E jsdomEnv(page))%0A      .then(window =%3E
  %7B%0A 
@@ -505,24 +505,26 @@
  =%3E %7B%0A      
+ 
+ 
 var blocks;%0A
@@ -524,16 +524,18 @@
 locks;%0A%0A
+  
       //
@@ -569,16 +569,18 @@
 t%0A      
+  
 global.d
@@ -593,19 +593,23 @@
 t = 
-jsdom(page)
+window.document
 ;%0A%0A 
@@ -605,32 +605,34 @@
 ocument;%0A%0A      
+  
 // Setup hljs en
@@ -637,24 +637,26 @@
 environment%0A
+  
       hljs.c
@@ -691,24 +691,26 @@
 ' %7D);%0A      
+  
 hljs.initHig
@@ -719,24 +719,26 @@
 ighting();%0A%0A
+  
       // Set
@@ -775,24 +775,26 @@
 tests%0A      
+  
 hljs.configu
@@ -811,24 +811,26 @@
 : true %7D);%0A%0A
+  
       blocks
@@ -874,16 +874,18 @@
 ;%0A      
+  
 _.each(b
@@ -917,26 +917,10 @@
 k);%0A
-%0A
   
-    done(err);%0A
     

Use promises for special case tests