Skip to content

Commit

Permalink
further fudging of qunit test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
brianleroux committed Mar 9, 2011
1 parent b23af85 commit 4308d27
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2009, 2010 Brian LeRoux
Copyright (c) 2009, 2010, 2011 Brian LeRoux

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
8 changes: 4 additions & 4 deletions src/adapters/webkit-sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Lawnchair.adapter('webkit-sqlite', (function () {
var that = this
, all = "SELECT * FROM " + this.name
, r = []
, cb = this.lambda(callback).bind(this) || undefined
, cb = this.fn(this.name, callback) || undefined
, win = function (xxx, results) {
if (results.rows.length != 0) {
for (var i = 0, l = results.rows.length; i < l; i++) {
Expand All @@ -163,7 +163,7 @@ Lawnchair.adapter('webkit-sqlite', (function () {
if (cb) cb.call(that, r)
}

this.db.transaction(function (t) {
this.db.transaction(function (t) {
t.executeSql(all, [], win, fail)
})
return this
Expand All @@ -181,8 +181,8 @@ Lawnchair.adapter('webkit-sqlite', (function () {
nuke: function (cb) {
var nuke = "DELETE FROM " + this.name
, that = this
, win = cb ? function(){ that.lambda(cb).bind(that)() } : function(){}
this.db.transaction(function (t) {
, win = cb ? function() { that.lambda(cb).call(that) } : function(){}
this.db.transaction(function (t) {
t.executeSql(nuke, [], win, fail)
})
return this
Expand Down
11 changes: 9 additions & 2 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@
<script src="../lib/lawnchair.js" type="text/javascript"></script>
<script src="lawnchair-spec.js" type="text/javascript"></script>

<script type="text/javascript">
var store = new Lawnchair({name:'tests'}, function(){})
<script type="text/javascript">
// autostart seems to be a little eager
QUnit.config.autostart = false
// kill qunit saves
sessionStorage.clear()
// kickup the chair
var store = new Lawnchair({name:'tests'}, function(){
QUnit.start()
})
</script>
</head>
<body>
Expand Down
32 changes: 21 additions & 11 deletions tests/lawnchair-spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


module('Lawnchair construction/destruction', {
setup:function() {
},
Expand Down Expand Up @@ -80,35 +82,44 @@ test( 'adding, nuking and size tests', function() {
test( 'shorthand callback syntax', function() {
QUnit.stop();
expect(4);
store.all('ok(true, "shorthand syntax callback gets evaled"); same(this, store, "`this` should be scoped to the Lawnchair instance"); QUnit.start();') ;
stop()
store.all('ok(true, "shorthand syntax callback gets evaled"); same(this, store, "`this` should be scoped to the Lawnchair instance"); QUnit.start(); QUnit.stop();') ;
var tmp = new Lawnchair({name:'temps', record:'tmp'}, function(){
QUnit.start()
var Temps = this;
equals(this, Temps, 'this is bound to Lawnchair')
stop()
Temps.all('start(); ok(temps, "this.name is passed to all callback")')
QUnit.stop()
Temps.all('ok(temps, "this.name is passed to all callback"); QUnit.start()')
})
})

test('scoped variable in shorthand callback', function() {
var tmp = new Lawnchair({name:'temps', record:'tmp'}, function(){
var Temps = this
stop()
Temps.each('start(); ok(tmp, "this.record is passed to each callback")')
expect(1)
QUnit.stop()
// FIXME fkn qunit being weird here... expect(1)
var tmp = new Lawnchair({name:'temps', record:'tmp'}, function() {
this.nuke(function() {
this.save({a:1}, function() {
this.each('ok(tmp, "this.record is passed to each callback"); QUnit.start()')
})
})
})
})

module('nuke()', {
setup:function() {
store.nuke();
QUnit.stop();
store.nuke(function() {
QUnit.start()
});
},
teardown:function() {
}
})

test( 'chainable', function() {
expect(1);
same(store.nuke(function() {}), store, 'should be chainable');
QUnit.stop()
same(store.nuke(function() { QUnit.start() }), store, 'should be chainable');
})

test( 'full callback syntax', function() {
Expand Down Expand Up @@ -312,4 +323,3 @@ test( 'remove functionality', function() {
//});
});
});
*/

0 comments on commit 4308d27

Please sign in to comment.