var expect = require('chai').expect;

var itCompilesChange = require('./util').itCompilesChange;
var describeWP2 = require('./util').describeWP2;

describeWP2('plugin webpack 2 use - builds changes', function() {

  itCompilesChange('plugin-uglify-1dep-es2015', {
    'index.js': [
      'import {key} from \'./obj\';',
      'console.log(key);',
    ].join('\n'),
  }, {
    'index.js': [
      'import {fib} from \'./obj\';',
      'console.log(fib(3));',
    ].join('\n'),
  }, function(output) {
    expect(output.run1['main.js'].toString()).to.contain('e.a');
    expect(output.run1['main.js'].toString()).to.not.contain('t.a');
    expect(output.run2['main.js'].toString()).to.contain('r.i(e.a)');
    expect(output.run2['main.js'].toString()).to.contain('t.a');
  });

  itCompilesChange('plugin-hmr-es2015', {
    'index.js': [
      'import {key} from \'./fib\';',
      'console.log(key);',
    ].join('\n'),
  }, {
    'index.js': [
      'import {fib} from \'./fib\';',
      'console.log(fib(3));',
    ].join('\n'),
  }, function(output) {
    expect(output.run1['main.js'].toString()).to.match(/return key/);
    expect(output.run1['main.js'].toString()).to.match(/\/* key/);
    expect(output.run2['main.js'].toString()).to.match(/exports\["a"\]/);
    expect(output.run2['main.js'].toString()).to.match(/\/* fib/);
    expect(Object.keys(output.run2).filter(function(key) {
      return /\.hot-update\.json/.test(key);
    })).to.length.of(2);
  });

});

@@ -489,39 +489,44 @@
 n(output) %7B%0A    
-expect(
+var main1 = 
 output.run1%5B'mai
@@ -546,40 +546,26 @@
 ng()
-).to.contain('e.a');%0A    expect(
+;%0A    var main2 = 
 outp
@@ -562,33 +562,33 @@
 in2 = output.run
-1
+2
 %5B'main.js'%5D.toSt
@@ -597,16 +597,128 @@
 ng()
+;%0A    var id1 = /var (%5Cw)=%5Cw%5C(0%5C)/.exec(main1)%5B1%5D;%0A    var id2 = /var (%5Cw)=%5Cw%5C(0%5C)/.exec(main2)%5B1%5D;%0A    expect(main1
 ).to
-.not
 .con
@@ -714,34 +714,39 @@
 in1).to.contain(
+id1 + 
 '
-t
 .a');%0A    expect
@@ -750,41 +750,65 @@
 ect(
-output.run2%5B'main.js'%5D.toString()
+main1).to.not.match(/(%5Cw%5C.a)=function/);%0A    expect(main2
 ).to
@@ -821,17 +821,27 @@
 in('r.i(
-e
+' + id2 + '
 .a)');%0A 
@@ -854,59 +854,42 @@
 ect(
-output.run2%5B'main.js'%5D.toString()).to.contain('t.a'
+main2).to.match(/(%5Cw%5C.a)=function/
 );%0A 

Improve plugin-uglify-1dep-es2015 test