'use strict';

require('mocha-given')
var chai       = require('chai')
var expect     = chai.expect
var context    = describe
var catchError = require('catch-error')
var sinon      = require('sinon')
var sinonChai  = require('sinon-chai')
chai.use(sinonChai)

var gjLayerControllerFactory = require('../lib/geojsonLayerController')

class Map {}
class KeyController {}
var dataServiceFactory = () => {
  return {}
}
var popupPresenterFactory = () => {
  return {}
}
var stylePresenterFactory = () => {
  return {}
}
var filterFactory = () => {
  return {}
}

var configBuilder = () => {
  return {
    map: new Map(),
    keyController: new KeyController(),
    dataServiceFactory: dataServiceFactory,
    popupPresenterFactory: popupPresenterFactory,
    stylePresenterFactory: stylePresenterFactory,
    filterFactory: filterFactory
  }
}

describe('geojsonLayerController', () => {
  describe('creating a geojsonLayerController', () => {
    var config, gjLayerController

    Given('some config', () => {
      config = configBuilder()
    })
    When('the module is called with config', () => {
      gjLayerController = gjLayerControllerFactory(config)
    })
    Then('the module should be an object', () => {
      expect(gjLayerController).to.be.an('object')
    })
  })


})

@@ -27,24 +27,59 @@
 cha-given')%0A
+var assert     = require('assert')%0A
 var chai    
@@ -99,16 +99,16 @@
 'chai')%0A
-
 var expe
@@ -870,16 +870,268 @@
 %0A  %7D%0A%7D%0A%0A
+var layerBuilder = (n) =%3E %7B%0A  assert(!!n && n %3E 0, 'layerBuilder requires a number greater than 0')%0A%0A  var layer = %7B%0A    name: 'layer',%0A    type: 'geojson'%0A  %7D%0A  var layers = %5B%5D%0A%0A  while (n %3E 0) %7B%0A    n--%0A    layers.push(layer)%0A  %7D%0A%0A  return layers%0A%7D%0A%0A
 describe
@@ -1376,24 +1376,24 @@
 g', () =%3E %7B%0A
-
       gjLaye
@@ -1561,12 +1561,509 @@
 )%0A  %7D)%0A%0A
+  describe('adding layers from config', () =%3E %7B%0A    var layerConfig, gjLayerController%0A%0A    Given('a valid geojsonLayerController', () =%3E %7B%0A      gjLayerController = gjLayerControllerFactory(configBuilder())%0A    %7D)%0A    Given('some layer config', () =%3E %7B%0A      layerConfig = layerBuilder(2)%0A    %7D)%0A    When('#addLayersFromConfig', () =%3E %7B%0A      gjLayerController(layerConfig)%0A    %7D)%0A    Then('the module should be an object', () =%3E %7B%0A      expect(gjLayerController).to.be.an('object')%0A    %7D)%0A  %7D)%0A%0A
 %0A%7D)%0A

Add WIP test for geojsonLayerController