define('dummy/tests/unit/sync-copying-test', ['ember', 'ember-qunit', 'qunit', 'dummy/tests/helpers/start-app', 'dummy/tests/helpers/fabricate'], function (Ember, ember_qunit, qunit, startApp, fabricate) {

  'use strict';

  var store;

  qunit.module("sync copying", {
    beforeEach: function beforeEach() {
      store = fabricate['default'](startApp['default'](), false);

      return Ember['default'].RSVP.all(["foo", "bar", "baz", "multi", "fooBar", "fooFix"].map(function (type) {
        return store.find(type);
      }));
    }
  });

  ember_qunit.test("it excludes attributes", function (assert) {
    assert.expect(1);

    var foo = store.getById("foo", "1");
    return Ember['default'].run(function () {
      return foo.copy({ property: null }).then(function (copy) {
        assert.equal(copy.get("property"), null);
      });
    });
  });

  ember_qunit.test("it shallow copies relation", function (assert) {
    assert.expect(1);

    var fooBar = store.getById("fooBar", "1");
    return Ember['default'].run(function () {
      return fooBar.copy().then(function (copy) {
        assert.equal(copy.get("fooFix.id"), "1");
      });
    });
  });

  ember_qunit.test("it copies belongsTo relation", function (assert) {
    assert.expect(2);

    var bar = store.getById("bar", "1");
    return Ember['default'].run(function () {
      return bar.copy().then(function (copy) {
        assert.notEqual(copy.get("foo.id"), bar.get("foo.id"));
        assert.equal(copy.get("foo.property"), "prop1");
      });
    });
  });

  ember_qunit.test("it copies hasMany relation", function (assert) {
    assert.expect(5);

    var baz = store.getById("baz", "1");
    return Ember['default'].run(function () {
      return baz.copy().then(function (copy) {
        assert.equal(copy.get("foos.length"), 2);
        assert.notEqual(copy.get("foos.firstObject.id"), "1");
        assert.notEqual(copy.get("foos.lastObject.id"), "2");
        assert.equal(copy.get("foos.firstObject.property"), "prop1");
        assert.equal(copy.get("foos.lastObject.property"), "prop2");
      });
    });
  });

  ember_qunit.test("it copies complex objects", function (assert) {
    assert.expect(6);

    var multi = store.getById("multi", "1");
    return Ember['default'].run(function () {
      return multi.copy().then(function (copy) {
        assert.notEqual(copy.get("bars.firstObject.id"), "1");
        assert.notEqual(copy.get("bars.firstObject.foo.id"), "1");
        assert.equal(copy.get("bars.firstObject.foo.property"), "prop1");
        assert.notEqual(copy.get("baz.id"), "1");
        assert.notEqual(copy.get("baz.foos.lastObject.id"), "2");
        assert.equal(copy.get("baz.foos.lastObject.property"), "prop2");
      });
    });
  });

  ember_qunit.test("it overwrites relations", function (assert) {
    assert.expect(2);

    var multi = store.getById("multi", "1");
    var myBaz = store.getById("baz", "2");
    return Ember['default'].run(function () {
      return multi.copy({ baz: myBaz, bars: [] }).then(function (copy) {
        assert.equal(copy.get("bars.length"), 0);
        assert.equal(copy.get("baz.foos.length"), myBaz.get("foos.length"));
      });
    });
  });

  ember_qunit.test("it excludes relations", function (assert) {
    assert.expect(2);

    var multi = store.getById("multi", "1");
    return Ember['default'].run(function () {
      return multi.copy({ baz: null }).then(function (copy) {
        assert.equal(copy.get("bars.firstObject.foo.property"), "prop1");
        assert.equal(copy.get("baz"), null);
      });
    });
  });

  ember_qunit.test("it copies empty objects", function (assert) {
    assert.expect(3);

    var multi = store.getById("multi", "2");
    return Ember['default'].run(function () {
      return multi.copy().then(function (copy) {
        assert.notEqual(copy.get("id"), "2");
        assert.equal(copy.get("bars.length"), 0);
        assert.equal(copy.get("baz.foos.firstObject.property"), "prop1");
      });
    });
  });

});