<commit_before>/* global google */
import Ember from 'ember';
import {
  moduleForComponent,
  test
} from 'ember-qunit';

function latRandomizer(){
  return (Math.random() * 181) - 90;
}

function lngRandomizer() {
  return (Math.random() * 281) -180;
}

moduleForComponent('street-view', {
  // specify the other units that are required for this test
  // needs: ['component:foo', 'helper:bar']
});

test('it renders', function(assert) {
  assert.expect(2);

  // creates the component instance
  var component = this.subject();
  assert.equal(component._state, 'preRender');

  // renders the component to the page
  this.render();
  assert.equal(component._state, 'inDOM');
});

test('that lat and lng are assigned properly', function ( assert ) {
  let lat = latRandomizer();
  let lng = lngRandomizer();

  let component = this.subject({
    lat: lat,
    lng: lng
  });
  this.render();

  assert.equal(component.lat.toFixed(3), component.panorama.position.G.toFixed(3));
  assert.equal(component.lng.toFixed(3), component.panorama.position.K.toFixed(3));

});

test('lat and lng are updated properly', function ( assert ) {
  let lat = latRandomizer();
  let lng = lngRandomizer();

  let component = this.subject({
    lat: lat,
    lng: lng
  });
  this.render();

  assert.equal(lat.toFixed(3), component.panorama.position.G.toFixed(3));
  assert.equal(lng.toFixed(3), component.panorama.position.K.toFixed(3));

  let newLat = latRandomizer();
  let newLng = lngRandomizer();

  component.setProperties({
    lat: newLat,
    lng: newLng
  });

  assert.equal(newLat.toFixed(3), component.panorama.position.G.toFixed(3));
  assert.equal(newLng.toFixed(3), component.panorama.position.K.toFixed(3));

});

test('that options are assigned properly to the map', function( assert ) {
  let component = this.subject();
  let height = Math.floor(Math.random() * 1000) + "px";
  let width = Math.floor(Math.random() * 1000) + "px";

  component.set('height', height);
  component.set('width', width);
  component.set('lat', latRandomizer());
  component.set('lng', lngRandomizer());
  component.set('pov', {
    heading: Math.floor(Math.random() * 200),
    pitch: Math.floor(Math.random() * 10)
  });
  component.set('zoom', Math.floor(Math.random() * 10));

  component.set('panControl', Boolean(Math.floor(Math.random() * 2)));
  if( component.panControl === true ) {
    component.set('panControlOptions', {
      position:google.maps.ControlPosition.RIGHT_TOP
    });
  }

  component.set('zoomControl', Boolean(Math.floor(Math.random() * 2)));
  if( component.zoomControl === true ) {
    component.set('zoomControlOptions', {
      style: google.maps.ZoomControlStyle.SMALL
    });

  }

  component.set('addressControl', Boolean(Math.floor(Math.random() * 2 )));
  if( component.addressControl === true) {
    component.set('addressControlOptions', {
      position: google.maps.ControlPosition.BOTTOM_CENTER
    });
  }

  component.set('linksControl', Boolean(Math.floor(Math.random() * 2 )));


  $().css({width: width, height: height});
  this.render();

  Ember.run(function() {
    let map = component.panorama;

    //position
    assert.equal(map.position.G.toFixed(3), component.lat.toFixed(3));
    assert.equal(map.position.K.toFixed(3), component.lng.toFixed(3));

    //pov
    assert.equal(map.pov.heading, component.pov.heading);
    assert.equal(map.pov.pitch, component.pov.pitch);

    //zoom
    assert.equal(map.zoom, component.zoom);

    // panControl
    assert.equal(map.panControl, component.panControl);<commit_msg>use public lat/lng getters in tests<commit_after>/* global google */
import Ember from 'ember';
import {
  moduleForComponent,
  test
} from 'ember-qunit';

function latRandomizer(){
  return (Math.random() * 181) - 90;
}

function lngRandomizer() {
  return (Math.random() * 281) -180;
}

moduleForComponent('street-view', {
  // specify the other units that are required for this test
  // needs: ['component:foo', 'helper:bar']
});

test('it renders', function(assert) {
  assert.expect(2);

  // creates the component instance
  var component = this.subject();
  assert.equal(component._state, 'preRender');

  // renders the component to the page
  this.render();
  assert.equal(component._state, 'inDOM');
});

test('that lat and lng are assigned properly', function ( assert ) {
  let lat = latRandomizer();
  let lng = lngRandomizer();

  let component = this.subject({
    lat: lat,
    lng: lng
  });
  this.render();

  assert.equal(component.lat.toFixed(3), component.panorama.getPosition().lat().toFixed(3));
  assert.equal(component.lng.toFixed(3), component.panorama.getPosition().lng().toFixed(3));

});

test('lat and lng are updated properly', function ( assert ) {
  let lat = latRandomizer();
  let lng = lngRandomizer();

  let component = this.subject({
    lat: lat,
    lng: lng
  });
  this.render();

  assert.equal(lat.toFixed(3), component.panorama.getPosition().lat().toFixed(3));
  assert.equal(lng.toFixed(3), component.panorama.getPosition().lng().toFixed(3));

  let newLat = latRandomizer();
  let newLng = lngRandomizer();

  component.setProperties({
    lat: newLat,
    lng: newLng
  });

  assert.equal(newLat.toFixed(3), component.panorama.getPosition().lat().toFixed(3));
  assert.equal(newLng.toFixed(3), component.panorama.getPosition().lng().toFixed(3));

});

test('that options are assigned properly to the map', function( assert ) {
  let component = this.subject();
  let height = Math.floor(Math.random() * 1000) + "px";
  let width = Math.floor(Math.random() * 1000) + "px";

  component.set('height', height);
  component.set('width', width);
  component.set('lat', latRandomizer());
  component.set('lng', lngRandomizer());
  component.set('pov', {
    heading: Math.floor(Math.random() * 200),
    pitch: Math.floor(Math.random() * 10)
  });
  component.set('zoom', Math.floor(Math.random() * 10));

  component.set('panControl', Boolean(Math.floor(Math.random() * 2)));
  if( component.panControl === true ) {
    component.set('panControlOptions', {
      position:google.maps.ControlPosition.RIGHT_TOP
    });
  }

  component.set('zoomControl', Boolean(Math.floor(Math.random() * 2)));
  if( component.zoomControl === true ) {
    component.set('zoomControlOptions', {
      style: google.maps.ZoomControlStyle.SMALL
    });

  }

  component.set('addressControl', Boolean(Math.floor(Math.random() * 2 )));
  if( component.addressControl === true) {
    component.set('addressControlOptions', {
      position: google.maps.ControlPosition.BOTTOM_CENTER
    });
  }

  component.set('linksControl', Boolean(Math.floor(Math.random() * 2 )));


  $().css({width: width, height: height});
  this.render();

  Ember.run(function() {
    let map = component.panorama;

    //position
    assert.equal(component.panorama.getPosition().lat().toFixed(3), component.lat.toFixed(3));
    assert.equal(component.panorama.getPosition().lng().toFixed(3), component.lng.toFixed(3));

    //pov
    assert.equal(map.pov.heading, component.pov.heading);
    assert.equal(map.pov.pitch, component.pov.pitch);

    //zoom
    assert.equal(map.zoom, component.zoom);

    // panControl
    assert.equal(map.panControl, component.panControl);
{'fraction_non_alphanumeric': 0.1710453539823009, 'fraction_numerical': 0.012997787610619468, 'mean_word_length': 4.061581525542337, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5439044', 'n_tokens_mistral': 2456, 'n_tokens_neox': 2343, 'n_words': 450}