-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e30383
commit 5968e55
Showing
8 changed files
with
113 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
"authors": [ | ||
"Pablo Vallejo <[email protected]>" | ||
], | ||
"description": "Lightweight JavaScript framework inspired in Backbone", | ||
"description": "Lightweight JavaScript MVC framework inspired in Backbone", | ||
"keywords": [ | ||
"javascript", | ||
"framework", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Test environment setup | ||
*/ | ||
(function() { | ||
|
||
// Setup config variables on test start | ||
QUnit.testStart(function() { | ||
|
||
var env = this.config.current.testEnvironment; | ||
|
||
// Capture Gillie.ajax arguments for comparison. | ||
// Adapted from https://github.com/jashkenas/backbone/blob/master/test/environment.js#L23 | ||
Gillie.ajax = function( settings ) { | ||
env.ajaxSettings = settings; | ||
} | ||
|
||
}); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Request Tests | ||
*/ | ||
|
||
$(document).ready(function(){ | ||
|
||
// Model | ||
var person; | ||
Person = Gillie.Model.extend({ | ||
|
||
// Base URL | ||
url: 'http://myapi.io' | ||
}); | ||
|
||
// Requests | ||
//---------------- | ||
module('Gillie requests', { | ||
|
||
setup: function() { | ||
|
||
// Create a new person | ||
person = new Person({ | ||
name: 'Fonzie', | ||
age: 40 | ||
}); | ||
} | ||
}); | ||
|
||
// Test Model.Post method | ||
test( 'Model.Post', function() { | ||
|
||
// Save user | ||
person.Post( '/person' ); | ||
|
||
// Get data | ||
var data = JSON.parse( this.ajaxSettings.data ); | ||
|
||
// Test equality | ||
equal( this.ajaxSettings.type, 'POST' ); | ||
equal( this.ajaxSettings.dataType, 'json' ); | ||
equal( this.ajaxSettings.url, 'http://myapi.io/person' ); | ||
equal( data.name, person.get( 'name' ) ); | ||
equal( data.age, person.get( 'age' ) ); | ||
|
||
}); | ||
|
||
// Test Model.Post passing a complete URL | ||
test( 'Model.Post full URL http', function() { | ||
|
||
// Save user | ||
person.Post( 'http://otherapi.io/person' ); | ||
|
||
// Get data | ||
var data = JSON.parse( this.ajaxSettings.data ); | ||
|
||
// Test equality | ||
equal( this.ajaxSettings.type, 'POST' ); | ||
equal( this.ajaxSettings.dataType, 'json' ); | ||
equal( this.ajaxSettings.url, 'http://otherapi.io/person' ); | ||
equal( data.name, person.get( 'name' ) ); | ||
equal( data.age, person.get( 'age' ) ); | ||
|
||
console.log( this.ajaxSettings ); | ||
|
||
}); | ||
|
||
// Test Model.Post passing a complete URL | ||
test( 'Model.Post full URL https', function() { | ||
|
||
// Save user | ||
person.Post( 'https://otherapi.io/person' ); | ||
equal( this.ajaxSettings.url, 'https://otherapi.io/person' ); | ||
}); | ||
|
||
// Test Model.Post passing a complete URL | ||
test( 'Model.Post full URL not https or http', function() { | ||
|
||
// Save user | ||
person.Post( 'ttps://otherapi.io/person' ); | ||
equal( this.ajaxSettings.url, 'http://myapi.iottps://otherapi.io/person' ); | ||
|
||
}); | ||
|
||
}); |