/* @flow */
const compileGluestickConfig = require('../compileGlueStickConfig');
const defaultConfig = require('../defaults/glueStickConfig');

describe('config/compileGluestickConfig', () => {
  it('should return default config', () => {
    expect(compileGluestickConfig([])).toEqual(defaultConfig);
  });

  it('should throw error', () => {
    const errorMessage = 'Invalid plugins argument';
    expect(() => {
      // $FlowIgnore
      compileGluestickConfig();
    }).toThrowError(errorMessage);
    expect(() => {
      // $FlowIgnore
      compileGluestickConfig(null);
    }).toThrowError(errorMessage);
    expect(() => {
      // $FlowIgnore
      compileGluestickConfig('string');
    }).toThrowError(errorMessage);
    expect(() => {
      // $FlowIgnore
      compileGluestickConfig(1);
    }).toThrowError(errorMessage);
    expect(() => {
      // $FlowIgnore
      compileGluestickConfig({});
    }).toThrowError(errorMessage);
  });

  it('should return overwriten config', () => {
    expect(compileGluestickConfig([
      // $FlowIgnore
      {
        name: 'testPlugin',
        overwrites: {
          gluestickConfig: (config) => {
            return Object.assign(config, { protocol: 'https' });
          },
        },
      },
      // $FlowIgnore
      {
        name: 'testPlugin',
        overwrites: {
          gluestickConfig: (config) => {
            return Object.assign(config, { host: 'test' });
          },
        },
      },
    ])).toEqual({ ...defaultConfig, protocol: 'https', host: 'test' });
  });
});

@@ -1170,39 +1170,28 @@
  return 
-Object.assign(
+%7B ...
 config,
- %7B
  protoco
@@ -1202,17 +1202,16 @@
 https' %7D
-)
 ;%0A      
@@ -1380,31 +1380,20 @@
 urn 
-Object.assign(
+%7B ...
 config,
- %7B
  hos
@@ -1399,25 +1399,24 @@
 st: 'test' %7D
-)
 ;%0A          

use spreat op.