/* global describe, it, */
/* eslint-disable handle-callback-err */

var unit = require('./parsekml');
var should = require('should');  // eslint-disable-line no-unused-vars


describe('parsekml', function () {

  it('should detect Placemark', function (done) {

    var xmlIn = '<?xml version="1.0" encoding="utf-8"?>' +
      '<kml xmlns="http://www.opengis.net/kml/2.2">' +
        '<Document>' +
          '<Placemark>' +
            '<name>Portland</name>' +
            '<Point>' +
              '<coordinates>-122.681944,45.52,0</coordinates>' +
            '</Point>' +
          '</Placemark>' +
        '</Document>' +
      '</kml>';

    unit(xmlIn, function (err, locs) {
      locs.should.deepEqual([
        {
          name: 'Portland',
          longitude: -122.681944,
          latitude: 45.52,
          descriptions: [],
          overlays: [],
        },
      ]);

      return done();
    });

  });

  it('should extract Folder', function (done) {

    var xmlIn = '<?xml version="1.0" encoding="utf-8"?>' +
      '<kml xmlns="http://www.opengis.net/kml/2.2">' +
        '<Document>' +
          '<Placemark>' +
            '<name>Rio de Janeiro</name>' +
            '<Point>' +
              '<coordinates>-43.196,-22.908,0</coordinates>' +
            '</Point>' +
          '</Placemark>' +
          '<Folder>' +
            '<GroundOverlay>' +
              '<name>Almeida</name>' +
                '<description><![CDATA[<a>Source</a>]]></description>' +
                '<Icon>' +
                  '<href>files/Almeida.jpg</href>' +
                  '<viewBoundScale>0.75</viewBoundScale>' +
                '</Icon>' +
                '<LatLonBox>' +
                  '<north>40.729</north>' +
                  '<south>40.722</south>' +
                  '<east>-6.900</east>' +
                  '<west>-6.912</west>' +
                  '<rotation>11.968</rotation>' +
                '</LatLonBox>' +
            '</GroundOverlay>' +
            '<Placemark>' +
              '<name>Portland</name>' +
              '<description><![CDATA[1234]]></description>' +
              '<Point>' +
                '<coordinates>-122.681,45.52,0</coordinates>' +
              '</Point>' +
            '</Placemark>' +
          '</Folder>' +
        '</Document>' +
      '</kml>';

    unit(xmlIn, function (err, locs) {
      locs.should.deepEqual([
        {
          name: 'Rio de Janeiro',
          latitude: -22.908,
          longitude: -43.196,
          descriptions: [],
          overlays: [],
        },
        {
          name: 'Portland',
          latitude: 45.52,
          longitude: -122.681,
          descriptions: ['1234'],
          overlays: [{
            name: 'Almeida',
            description: '<a>Source</a>',
            href: 'files/Almeida.jpg',
            viewBoundScale: 0.75,
            latLonBox: {
              north: 40.729,
              south: 40.722,
              east: -6.900,
              west: -6.912,
              rotation: 11.968,
            },
          }],
        },
      ]);

      return done();
    });

  });

});

@@ -1413,34 +1413,32 @@
 +%0A              
-  
 '%3Cdescription%3E%3C!
@@ -1492,18 +1492,16 @@
         
-  
 '%3CIcon%3E'
@@ -1495,34 +1495,32 @@
      '%3CIcon%3E' +%0A
-  
                 
@@ -1570,18 +1570,16 @@
         
-  
 '%3CviewBo
@@ -1626,18 +1626,16 @@
         
-  
 '%3C/Icon%3E
@@ -1630,34 +1630,32 @@
     '%3C/Icon%3E' +%0A
-  
               '%3C
@@ -1684,18 +1684,16 @@
         
-  
 '%3Cnorth%3E
@@ -1706,26 +1706,24 @@
 %3C/north%3E' +%0A
-  
             
@@ -1748,26 +1748,24 @@
 %3C/south%3E' +%0A
-  
             
@@ -1808,18 +1808,16 @@
         
-  
 '%3Cwest%3E-
@@ -1828,26 +1828,24 @@
 2%3C/west%3E' +%0A
-  
             
@@ -1872,34 +1872,32 @@
 8%3C/rotation%3E' +%0A
-  
               '%3C

Fix indentation