Skip to content

Commit

Permalink
Fix Sammy.Flash tests
Browse files Browse the repository at this point in the history
  • Loading branch information
quirkey committed Jul 11, 2011
1 parent a713d5e commit 28ec025
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/plugins/sammy.flash.js
Expand Up @@ -9,7 +9,7 @@
Sammy.FlashHash.prototype = {
// @return [String] this Flash, rendered as an <ul>.
toHTML: function() {
result = this._renderUL();
var result = this._renderUL();
this.clear();
return result;
},
Expand All @@ -31,7 +31,7 @@
var key;
for (key in hash) {
if (key !== 'now' && hash.hasOwnProperty(key)) {
hash[key] = undefined;
delete hash[key];
}
}
},
Expand Down
14 changes: 6 additions & 8 deletions test/test_sammy_flash.js
Expand Up @@ -2,8 +2,7 @@
with(QUnit) {

var createAppsWithFlash = function() {
this.app = new Sammy.Application(function() {
this.element_selector = '#form_params';
this.app = Sammy('#form_params', function() {
this.use(Sammy.Flash);
this.get('#/', function() {
this.flash('welcome info', 'Welcome!');
Expand All @@ -14,8 +13,7 @@
});
});

this.nowApp = new Sammy.Application(function() {
this.element_selector = '#main';
this.nowApp = Sammy('#main', function() {
this.use(Sammy.Flash);
this.get('#/', function() {
this.flashNow('info', '您好');
Expand All @@ -28,9 +26,8 @@
});
});

this.app.run('/#');
this.nowApp.run('/#');
window.location.hash = '#/';
this.app.run('#/');
this.nowApp.run('#/');
};

var unloadAppsWithFlash = function() {
Expand Down Expand Up @@ -73,6 +70,7 @@
ok(this.nowApp.flash.now);
})
.should('retain entries after a non-redirect', function() {
window.location.hash = '#/';
equal(this.nowApp.flash.now.info, '您好');
})
.should('lose all entries after a redirect', function() {
Expand All @@ -83,7 +81,7 @@
}, this, 2, 2);
})
.should('lose all entries after being rendered', function() {
this.app.flash.toHTML();
this.nowApp.flash.toHTML();
equal(this.nowApp.flash.now.info, null);
equal(this.nowApp.flash.now.warn, null);
})
Expand Down

0 comments on commit 28ec025

Please sign in to comment.