Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

Commit

Permalink
added tests for resourceUrl() and duplicateProperties()
Browse files Browse the repository at this point in the history
  • Loading branch information
dgeb committed Feb 27, 2012
1 parent 015e7e0 commit b1b6404
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/tests/ember-resource.js
Expand Up @@ -11,7 +11,7 @@ module("Ember.Resource", {
});

test("should serialize its properties to JSON", function() {
var props = {"id": 1, "first_name": "Joe", "last_name": "Blow"};
var props = {id: 1, first_name: "Joe", last_name: "Blow"};

var contact = Contact.create(props);
var serialized = contact.serialize();
Expand All @@ -21,7 +21,7 @@ test("should serialize its properties to JSON", function() {
});

test("should deserialize its properties to JSON", function() {
var props = {"id": 1, "first_name": "Joe", "last_name": "Blow"};
var props = {id: 1, first_name: "Joe", last_name: "Blow"};

var contact = Contact.create();
contact.deserialize(props);
Expand All @@ -31,6 +31,20 @@ test("should deserialize its properties to JSON", function() {
equal(contact.get("last_name"), props.last_name, "last_name matches");
});

test("should duplicate properties from another resource", function() {
var contact = Contact.create({id: 1, first_name: "Joe", last_name: "Blow"});
var contact2 = Contact.create();
contact2.duplicateProperties(contact);

equal(contact2.get("first_name"), contact.get("first_name"), "first_name matches");
equal(contact2.get("last_name"), contact.get("last_name"), "last_name matches");
});

test("should determine a resourceUrl based upon id", function() {
var contact = Contact.create({id: 1});
equal(contact._resourceUrl(), "/contacts/1");
});

test("should find a resource via ajax", function() {
server.respondWith("GET", "/contacts/1",
[200,
Expand Down

0 comments on commit b1b6404

Please sign in to comment.