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

import { projection, projectionFrom, projectionTo } from './projection.utils';

describe('Projection Utils', () => {
  describe('projectionFrom-to', () => {
    it('should be created', () => {
      expect(projectionFrom('A').to('B')).toBeTruthy();
    });

    it('should project geometry', () => {
      const geometry = {
        transform: jest.fn(),
      };
      projectionFrom('A').to('B')(<any>geometry);
      expect(geometry.transform.mock.calls[geometry.transform.mock.calls.length - 1]).toEqual(['A', 'B']);
    });
  });

  describe('projectionTo-from', () => {
    it('should be created', () => {
      expect(projectionTo('A').from('B')).toBeTruthy();
    });

    it('should project geometry', () => {
      const geometry = {
        transform: jest.fn(),
      };
      projectionTo('A').from('B')(<any>geometry);
      expect(geometry.transform.mock.calls[geometry.transform.mock.calls.length - 1]).toEqual(['B', 'A']);
    });
  });

  describe('projection', () => {
    it('should be created', () => {
      expect(projection('A')).toBeTruthy();
    });

    it('to should project geometry from to target projection', () => {
      const geometry = {
        transform: jest.fn(),
      };
      projection('A').to('B')(<any>geometry);
      expect(geometry.transform.mock.calls[geometry.transform.mock.calls.length - 1]).toEqual(['A', 'B']);
    });

    it('from should project geometry from source projection', () => {
      const geometry = {
        transform: jest.fn(),
      };
      projection('A').from('B')(<any>geometry);
      expect(geometry.transform.mock.calls[geometry.transform.mock.calls.length - 1]).toEqual(['B', 'A']);
    });
  });
});
