import {
  moduleForComponent,
  test
} from 'ember-qunit';
import Ember from "ember";

var get = Ember.get;
var set = Ember.set;
var run = Ember.run;

moduleForComponent('popup-menu', 'PopupMenuComponent');

test('"for" takes an string id', function() {
  expect(1);

  // creates the component instance
  var component = this.subject({
    on: "click"
  });
  set(component, 'for', "ember-testing-container");
  equal(get(component, 'targetElement'), document.getElementById("ember-testing-container"));
});

test('"for" takes an element', function() {
  expect(1);

  // creates the component instance
  var component = this.subject({
    on: "click"
  });
  var element = document.getElementById("ember-testing-container");
  set(component, 'for', element);
  equal(get(component, 'targetElement'), element);
});

test('"for" takes a view', function() {
  expect(2);

  // creates the component instance
  var component = this.subject({
    on: "click"
  });
  this.append();

  var view = get(component, 'parentView');
  ok(view);
  var element = get(view, 'element');
  set(component, 'for', view);
  equal(get(component, 'targetElement'), element);
});

test('"retile" is called when will-change properties change', function() {
  expect(4);

  var RETILE_CALLED = false;

  // creates the component instance
  var component = this.subject({
    on: "click",
    retile: function () {
      RETILE_CALLED = true;
    }
  });

  run(function () {
    set(component, 'willChange', "text");
  });
  ok(RETILE_CALLED);

  RETILE_CALLED = false;
  run(function () {
    set(component, 'text', "Hello");
  });
  ok(RETILE_CALLED);

  RETILE_CALLED = false;
  run(function () {
    set(component, 'willChange', null);
  });
  ok(RETILE_CALLED);

  RETILE_CALLED = false;
  run(function () {
    set(component, 'text', "Hello");
   });
  ok(!RETILE_CALLED);
});

@@ -1850,12 +1850,909 @@
 ALLED);%0A%7D);%0A
+%0Atest('classNames are applied when pointer and orientation are set', function() %7B%0A  expect(5);%0A%0A  // creates the component instance%0A  var component = this.subject(%7B%0A    on: %22click%22%0A  %7D);%0A  this.append();%0A%0A  var $ = component.$();%0A  equal($.prop('class'), %22ember-view popup-menu%22);%0A%0A  run(function () %7B%0A    set(component, 'orientation', 'above');%0A  %7D);%0A  equal($.prop('class'), %22ember-view popup-menu orient-above%22);%0A%0A  run(function () %7B%0A    set(component, 'orientation', 'below');%0A    set(component, 'pointer', 'center');%0A  %7D);%0A  equal($.prop('class'), %22ember-view popup-menu orient-below pointer-center%22);%0A%0A  run(function () %7B%0A    set(component, 'orientation', null);%0A    set(component, 'pointer', 'left');%0A  %7D);%0A  equal($.prop('class'), %22ember-view popup-menu pointer-left%22);%0A%0A  run(function () %7B%0A    set(component, 'pointer', null);%0A  %7D);%0A  equal($.prop('class'), %22ember-view popup-menu%22);%0A%7D);%0A

add tests for classNameBindings