Skip to content

Instantly share code, notes, and snippets.

@RyanHirsch
Created July 15, 2013 23:12
Show Gist options
  • Save RyanHirsch/6004320 to your computer and use it in GitHub Desktop.
Save RyanHirsch/6004320 to your computer and use it in GitHub Desktop.
FixtureAdapter test
var FixtureModel, adapter;
module("Ember.FixtureAdapter", {
setup: function() {
FixtureModel = Ember.Model.extend({
name: Ember.attr()
});
adapter = FixtureModel.adapter = Ember.FixtureAdapter.create();
}
});
test("findAll loads the full FIXTURES payload when collectionKey isn't specified", function() {
expect(1);
var data = [
{id: 1, name: 'Erik'},
{id: 2, name: 'Aaron'}
],
records;
FixtureModel.collectionKey = undefined;
FixtureModel.FIXTURES = data;
Ember.run(function() {
records = FixtureModel.findAll();
});
equal(records.get('length'), data.length, "The proper number of items should have been loaded.");
});
@RyanHirsch
Copy link
Author

var FixtureModel, adapter;

module("Ember.FixtureAdapter", {
  setup: function() {
    FixtureModel = Ember.Model.extend({
      id: Ember.attr(),
      name: Ember.attr()
    });
    adapter = FixtureModel.adapter = Ember.FixtureAdapter.create();
  }
});

test("findAll loads the full FIXTURES payload when collectionKey isn't specified", function() {
  expect(1);

  var data = [
      {id: 1, name: 'Erik'},
      {id: 2, name: 'Aaron'}
    ],
    // records,
    promise;
  FixtureModel.collectionKey = undefined;

  FixtureModel.FIXTURES = data;

  var promise = FixtureModel.fetch();
  promise.then(function(records) {
    equal(records.get('length'), data.length, "The proper number of items should have been loaded.");
  });

});

Results in

Expected 1 assertions, but 0 were run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment