Permalink
Browse files

added jshint

  • Loading branch information...
1 parent b1970a9 commit 27b210cf1c65a75b130485ead79ed13694e84915 @staugaard staugaard committed Nov 20, 2011
Showing with 64 additions and 33 deletions.
  1. +1 −0 Gemfile
  2. +5 −2 Rakefile
  3. +0 −2 spec/javascripts/associationsSpec.js
  4. +58 −29 spec/javascripts/toJSONSpec.js
View
@@ -1,5 +1,6 @@
source "http://rubygems.org"
gem 'jasmine', '1.1.0'
+gem 'jshint'
gem 'rake'
gem 'rails', ">= 3.0" #for some reason travis-ci.org wants this
View
@@ -1,6 +1,5 @@
require 'bundler/setup'
require 'pathname'
-Bundler.require
namespace :jasmine do
@@ -58,4 +57,8 @@ desc "Run specs via server"
task :jasmine => ['jasmine:server']
-task :default => 'jasmine:ci'
+require 'jshint/tasks'
+JSHint.config_path = 'jshint.yml'
+
+
+task :default => ['jshint', 'jasmine:ci']
@@ -61,8 +61,6 @@ describe('associations', function() {
var instance = Person.create({}, data);
var address = instance.get('address');
- debugger
-
expect(address instanceof Address).toBe(true);
expect(address.get('street')).toBe('1 My Street');
expect(address.get('zip')).toBe(12345);
@@ -1,42 +1,71 @@
describe('toJSON', function() {
- var Address = SC.Resource.define({
- schema: {
- city: String,
- }
- });
+ describe('of nested objects', function() {
+ var Address = SC.Resource.define({
+ schema: {
+ city: String
+ }
+ });
- var Person = SC.Resource.define({
- schema: {
- id: Number,
- name: String,
+ var Person = SC.Resource.define({
+ schema: {
+ id: Number,
+ name: String,
+ address: {
+ type: Address,
+ nested: true
+ }
+ }
+ });
+
+ var attributes = {
+ name: 'John Smit',
address: {
- type: Address,
- nested: true
+ city: 'London'
}
- }
- });
+ };
- var attributes = {
- name: 'John Smit',
- address: {
- city: 'London',
- }
- };
+ it('should return updated values of nested objects', function() {
+ var person = Person.create(attributes),
+ newCity = 'Liverpool',
+ newName = 'Smit Johnson';
- it('should return updated values of nested objects', function() {
- var person = Person.create(attributes),
- newCity = 'Liverpool',
- newName = 'Smit Johnson';
+ SC.setPath(person, 'address.city', newCity);
+ SC.set(person, 'name', newName);
- SC.setPath(person, 'address.city', newCity);
- SC.set(person, 'name', newName);
+ var json = person.toJSON();
- var json = person.toJSON();
+ expect(json).toEqual({
+ name: newName,
+ address: { city: newCity }
+ });
+ });
+ });
- expect(json).toEqual({
- name: newName,
- address: { city: newCity }
+ describe('of remote has one associations', function() {
+ var Address = SC.Resource.define({
+ schema: {
+ id: Number,
+ city: String
+ }
+ });
+
+ var Person = SC.Resource.define({
+ schema: {
+ id: Number,
+ name: String,
+ address: { type: Address }
+ }
});
+
+ it('should return the id of the association at the path', function() {
+ var address = Address.create({id: 1, city: 'San Francisco'});
+ var person = Person.create({id: 1, name: 'Mick Staugaard', address: address});
+
+ var json = person.toJSON();
+ expect(json.address).toBeUndefined();
+ expect(json.address_id).toBe(1);
+ });
+
});
});

0 comments on commit 27b210c

Please sign in to comment.