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
bb7ffe6
commit f5ed2de
Showing
9 changed files
with
322 additions
and
321 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
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
(function() { | ||
describe('joli.connexion', function() { | ||
var test = new joliTest(); | ||
describe('joli.connexion', function() { | ||
var test = new joliTest(); | ||
|
||
/** | ||
* Set up the test conditions | ||
*/ | ||
var setUp = function() { | ||
test.clearTables(); | ||
test.insertCity(); | ||
}; | ||
/** | ||
* Set up the test conditions | ||
*/ | ||
var setUp = function() { | ||
test.clearTables(); | ||
test.insertCity(); | ||
}; | ||
|
||
it('joli.Connection.lastInsertRowId()', function() { | ||
setUp(); | ||
it('joli.Connection.lastInsertRowId()', function() { | ||
setUp(); | ||
|
||
// retrieve the last inserted id | ||
// retrieve the last inserted id | ||
var id = joli.connection.lastInsertRowId(); | ||
expect(id).toBeGreaterThan(0); | ||
expect(id).toBeGreaterThan(0); | ||
|
||
// retrieve this city from its id | ||
var city = models.city.findOneById(id); | ||
expect(city).not.toBeNull(); | ||
expect(city.get('name')).toBe('New York'); | ||
}); | ||
}); | ||
// retrieve this city from its id | ||
var city = models.city.findOneById(id); | ||
expect(city).not.toBeNull(); | ||
expect(city.get('name')).toBe('New York'); | ||
}); | ||
}); | ||
})(); |
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 |
---|---|---|
@@ -1,95 +1,95 @@ | ||
(function() { | ||
describe('joli.model', function() { | ||
var test = new joliTest(); | ||
|
||
/** | ||
* Set up the test conditions | ||
*/ | ||
var setUp = function() { | ||
test.clearTables(); | ||
}; | ||
|
||
it('joli.model.truncate()', function() { | ||
setUp(); | ||
|
||
models.city.truncate(); | ||
models.country.truncate(); | ||
models.human.truncate(); | ||
|
||
expect(models.city.count()).toBe(0); | ||
expect(models.country.count()).toBe(0); | ||
expect(models.human.count()).toBe(0); | ||
}); | ||
|
||
it('joli.model.all()', function() { | ||
test.insertCities(); | ||
var cities = models.city.all(); | ||
|
||
expect(cities.length).toBe(2); | ||
expect(cities[0].get('name')).toBe('New York'); | ||
expect(cities[1].get('name')).toBe('Paris'); | ||
}); | ||
|
||
it('joli.model.count()', function() { | ||
test.createHumans(); | ||
expect(models.human.count()).toBe(1); | ||
}); | ||
|
||
it('joli.model.deleteRecords()', function() { | ||
models.human.deleteRecords(test.sarah.get('id')); | ||
expect(models.human.count()).toBe(0); | ||
|
||
test.createHumans(); | ||
test.john.save(); | ||
expect(models.human.count()).toBe(2); | ||
|
||
models.human.deleteRecords([ | ||
test.john.get('id'), | ||
test.sarah.get('id') | ||
]); | ||
|
||
expect(models.human.count()).toBe(0); | ||
}); | ||
|
||
it('joli.model.exists()', function() { | ||
expect(models.human.exists(test.sarah.get('id'))).toBeFalsy(); | ||
|
||
test.createHumans(); | ||
expect(models.human.exists(test.sarah.get('id'))).toBeTruthy(); | ||
}); | ||
|
||
it('joli.model.findBy()', function() { | ||
test.clearTables(); | ||
test.createManyItems(); | ||
|
||
var paris_id = models.city.findOneBy('name', 'Paris').get('id'); | ||
var livingInParis = models.human.findBy('city_id', paris_id); | ||
|
||
joli.each(livingInParis, function(item, key) { | ||
expect(item.city_id).toBe(paris_id); | ||
}); | ||
}); | ||
|
||
it('joli.model.findOneBy()', function() { | ||
expect(models.city.findOneBy('name', 'Paris')).not.toBeNull(); | ||
expect(models.city.findOneBy('name', 'InexistantCity')).toBeFalsy(); | ||
}); | ||
|
||
it('joli.model.getColumns()', function() { | ||
expect(models.city.getColumns()).toEqual({ | ||
describe('joli.model', function() { | ||
var test = new joliTest(); | ||
|
||
/** | ||
* Set up the test conditions | ||
*/ | ||
var setUp = function() { | ||
test.clearTables(); | ||
}; | ||
|
||
it('joli.model.truncate()', function() { | ||
setUp(); | ||
|
||
models.city.truncate(); | ||
models.country.truncate(); | ||
models.human.truncate(); | ||
|
||
expect(models.city.count()).toBe(0); | ||
expect(models.country.count()).toBe(0); | ||
expect(models.human.count()).toBe(0); | ||
}); | ||
|
||
it('joli.model.all()', function() { | ||
test.insertCities(); | ||
var cities = models.city.all(); | ||
|
||
expect(cities.length).toBe(2); | ||
expect(cities[0].get('name')).toBe('New York'); | ||
expect(cities[1].get('name')).toBe('Paris'); | ||
}); | ||
|
||
it('joli.model.count()', function() { | ||
test.createHumans(); | ||
expect(models.human.count()).toBe(1); | ||
}); | ||
|
||
it('joli.model.deleteRecords()', function() { | ||
models.human.deleteRecords(test.sarah.get('id')); | ||
expect(models.human.count()).toBe(0); | ||
|
||
test.createHumans(); | ||
test.john.save(); | ||
expect(models.human.count()).toBe(2); | ||
|
||
models.human.deleteRecords([ | ||
test.john.get('id'), | ||
test.sarah.get('id') | ||
]); | ||
|
||
expect(models.human.count()).toBe(0); | ||
}); | ||
|
||
it('joli.model.exists()', function() { | ||
expect(models.human.exists(test.sarah.get('id'))).toBeFalsy(); | ||
|
||
test.createHumans(); | ||
expect(models.human.exists(test.sarah.get('id'))).toBeTruthy(); | ||
}); | ||
|
||
it('joli.model.findBy()', function() { | ||
test.clearTables(); | ||
test.createManyItems(); | ||
|
||
var paris_id = models.city.findOneBy('name', 'Paris').get('id'); | ||
var livingInParis = models.human.findBy('city_id', paris_id); | ||
|
||
joli.each(livingInParis, function(item, key) { | ||
expect(item.city_id).toBe(paris_id); | ||
}); | ||
}); | ||
|
||
it('joli.model.findOneBy()', function() { | ||
expect(models.city.findOneBy('name', 'Paris')).not.toBeNull(); | ||
expect(models.city.findOneBy('name', 'InexistantCity')).toBeFalsy(); | ||
}); | ||
|
||
it('joli.model.getColumns()', function() { | ||
expect(models.city.getColumns()).toEqual({ | ||
id: 'INTEGER PRIMARY KEY AUTOINCREMENT', | ||
country_id: 'INTEGER', | ||
name: 'TEXT', | ||
description: 'TEXT' | ||
}); | ||
}); | ||
|
||
it('model methods only for persisted items', function() { | ||
test.clearTables(); | ||
test.insertCities(); | ||
test.createHumans(); | ||
expect(models.human.countIn('Paris')).toBe(0); | ||
expect(models.human.countIn('New York')).toBe(1); | ||
}); | ||
}); | ||
}); | ||
|
||
it('model methods only for persisted items', function() { | ||
test.clearTables(); | ||
test.insertCities(); | ||
test.createHumans(); | ||
expect(models.human.countIn('Paris')).toBe(0); | ||
expect(models.human.countIn('New York')).toBe(1); | ||
}); | ||
}); | ||
})(); |
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
(function() { | ||
describe('joli.models', function() { | ||
var test = new joliTest(); | ||
describe('joli.models', function() { | ||
var test = new joliTest(); | ||
|
||
it('joli.models.get()', function() { | ||
expect(joli.models.get('city')).toBe(models.city); | ||
expect(joli.models.get('city')).not.toBe(models.human); | ||
}); | ||
it('joli.models.get()', function() { | ||
expect(joli.models.get('city')).toBe(models.city); | ||
expect(joli.models.get('city')).not.toBe(models.human); | ||
}); | ||
|
||
it('joli.models.has()', function() { | ||
expect(joli.models.has('city')).toBeTruthy(); | ||
expect(joli.models.has('inexistant_model')).toBeFalsy(); | ||
}); | ||
}); | ||
it('joli.models.has()', function() { | ||
expect(joli.models.has('city')).toBeTruthy(); | ||
expect(joli.models.has('inexistant_model')).toBeFalsy(); | ||
}); | ||
}); | ||
})(); |
Oops, something went wrong.