/*
 * Copyright (C) 2018 Robert Bosch GmbH Copyright (C) 2018 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { MapEditorPage } from '../support/map-editor.po';

describe('MapEditorComponent', () => {
  let page: MapEditorPage;

  before(() => {
    page = new MapEditorPage();
    page.navigateTo();
  });

  describe('when drawing', () => {
    it('should be empty', () => { // TODO
      // Open Last Changed Feature accordion in order to see it's content
      page.openLastChangedFeatureHeader();
      page.getLastChangedFeature().then(($el) => {
        expect($el.text().trim()).to.eq('');
      });

      page.getVectorLayerExport().then(($el) => {
        expect($el.text().trim()).to.eq('');
      });
    });

    it('then should draw polyline', () => {
      page.enterPolylineMode();
      page.drawPoly([
        [100, 100],
        [100, 200],
        [200, 300],
      ]);
      page.getLastChangedFeature().should('contain.text', '"type": "LineString"');
      page.getVectorLayerExport().should('contain.value', '"type": "LineString"');
    });

    it('then should add polygon', () => {
      page.enterPolygonMode();
      page.drawPoly([
        [200, 300],
        [300, 300],
        [300, 400],
      ]);
      page.getLastChangedFeature().should('not.contain.text', '"type": "LineString"');
      page.getLastChangedFeature().should('contain.text', '"type": "Polygon"');

      page.getVectorLayerExport().should('contain.value', '"type": "Polygon"');
      page.getVectorLayerExport().should('contain.value', '"type": "LineString"');
    });
  });
});
