'use strict';

var should = require('chai').should(); // eslint-disable-line
var prefixer = require('../lib/filter');

var nonStandards = ['-webkit-', '-moz-'];

function makeCSS(prefix) {
  var isNS = nonStandards.indexOf(prefix) !== -1;

  return ':%s%d div { color: white;  }'
    .replace('%s', prefix || '')
    .replace('%d', isNS ? 'full-screen' : 'fullscreen');
}

describe('hexo-autoprefixer', function() {
  it('should prefix fullscreen with no excludes', function() {
    var ctx = {
      config: {
        autoprefixer: {
          exclude: null
        }
      }
    };
    var unprefixed = makeCSS();
    var newCSS = prefixer.call(ctx, unprefixed, {
      path: '/usr/foo/bar/baz.css'
    });

    ['-webkit-', '-moz-', '-ms-'].map(makeCSS).concat(unprefixed).join('\n').should.eql(newCSS);
  });

  it('should prefix fullscreen with string exclude', function() {
    var ctx = {
      config: {
        autoprefixer: {
          exclude: '*.styl'
        }
      }
    };
    var unprefixed = makeCSS();
    var newCSS = prefixer.call(ctx, unprefixed, {
      path: '/usr/foo/bar/baz.css'
    });

    ['-webkit-', '-moz-', '-ms-'].map(makeCSS).concat(unprefixed).join('\n').should.eql(newCSS);
  });

  it('should not prefix fullscreen with exclude match', function() {
    var ctx = {
      config: {
        autoprefixer: {
          exclude: '/**/*.styl'
        }
      }
    };
    var unprefixed = makeCSS();
    var newCSS = prefixer.call(ctx, unprefixed, {
      path: '/usr/baz.styl'
    });

    unprefixed.should.eql(newCSS);
  });
});

@@ -12,364 +12,278 @@
 ';%0A%0A
-var should = require('chai').should(); // eslint-disable-line%0Avar prefixer = require('../lib/filter');%0A%0Avar nonStandards = %5B'-webkit-', '-moz-'%5D;%0A%0Afunction makeCSS(prefix) %7B%0A  var isNS = nonStandards.indexOf(prefix) !== -1;%0A%0A  return ':%25s%25d div %7B color: white;  %7D'%0A    .replace('%25s', prefix %7C%7C '')%0A    .replace('%25d', isNS ? 'full-screen' : 'fullscreen');%0A%7D
+require('chai').use(require('chai-as-promised')).should();%0Avar prefixer = require('../lib/filter');%0A%0Aconst unprefixed = 'div %7B user-select: none; %7D';%0Aconst prefixed = 'div %7B -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; %7D';
 %0A%0Ade
@@ -495,40 +495,8 @@
  %7D;%0A
-    var unprefixed = makeCSS();%0A
     
@@ -593,98 +593,37 @@
     
-%5B'-webkit-', '-moz-', '-ms-'%5D.map(makeCSS).concat(unprefixed).join('%5Cn').should.eql(newCSS
+newCSS.should.become(prefixed
 );%0A 
@@ -807,40 +807,8 @@
  %7D;%0A
-    var unprefixed = makeCSS();%0A
     
@@ -905,98 +905,37 @@
     
-%5B'-webkit-', '-moz-', '-ms-'%5D.map(makeCSS).concat(unprefixed).join('%5Cn').should.eql(newCSS
+newCSS.should.become(prefixed
 );%0A 
@@ -1126,40 +1126,8 @@
  %7D;%0A
-    var unprefixed = makeCSS();%0A
     
@@ -1217,36 +1217,39 @@
     
-unprefixed.should.eql(newCSS
+newCSS.should.become(unprefixed
 );%0A 

use chai-as-promised