import expect from 'expect';
import conf from '../';

describe('conf function', () => {
  it('should return undefined if "conf" is not provided', () => {
    const props = {};
    expect(conf(props)).toBe(undefined);
  });

  it('should return the "conf" props unless its child "conf" key', () => {
    const props = {conf: {
      foo: 'bar',
      conf: 'shouldNotCopy'
    }};
    expect(conf(props)).toEqual({foo: 'bar'});
  });

  it('should return the "conf" computed props if callback', () => {
    const props = {conf: {
      foo: () => ('bar')
    }};
    expect(conf(props)).toEqual({foo: 'bar'});
  });

  it('should return undefined if child "conf" is not provided', () => {
    const props = {};
    expect(conf(1, props)).toBe(undefined);
    expect(conf('div', props)).toBe(undefined);
  });

  it('should return the indexed child "conf"', () => {
    const props = {conf: {
      conf: [{foo: 'bar'}, {bar: 'baz'}]
    }};
    expect(conf(0, props)).toEqual({foo: 'bar'});
    expect(conf(1, props)).toEqual({bar: 'baz'});
  });

  it('should return the named child "conf"', () => {
    const props = {conf: {
      conf: {
        div: {foo: 'bar'},
        SomeComponent: {bar: 'baz'}
      }
    }};
    expect(conf('div', props)).toEqual({foo: 'bar'});
    expect(conf('SomeComponent', props)).toEqual({bar: 'baz'});
  });
});

@@ -1336,13 +1336,368 @@
 );%0A  %7D);
+%0A%0A  it('should return the child %22conf%22 computed props', () =%3E %7B%0A    const iprops = %7Bconf: %7B%0A      conf: %5B%7B%0A        foo: () =%3E ('bar')%0A      %7D%5D%0A    %7D%7D;%0A    expect(conf(0, iprops)).toEqual(%7Bfoo: 'bar'%7D);%0A%0A    const nprops = %7Bconf: %7B%0A      conf: %7Bdiv: %7B%0A        foo: () =%3E ('bar')%0A      %7D%7D%0A    %7D%7D;%0A    expect(conf('div', nprops)).toEqual(%7Bfoo: 'bar'%7D);%0A  %7D);
 %0A%7D);%0A

add conf tests