Skip to content

Commit

Permalink
Tests for specific API
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Apr 16, 2013
1 parent f52efa4 commit d079aaf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/sessions/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Flash.prototype = new (function () {
message = JSON.stringify(message);
}
}
messages[type] = mesages[type] || [];
messages[type] = messages[type] || [];
messages[type].push(message);
this.session.set('flashMessages', messages);
};
Expand Down
22 changes: 11 additions & 11 deletions test/sessions/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,32 @@ tests = {
var flash = new Flash(sessionMock);
assert.ok(flash instanceof Flash);

flash.add('foo error','error');
flash.add('foo bar error','error');
flash.add('foo info','info');
flash.add('foo success','success');
flash.add('foo custom','custom');
flash.addMessage('foo error','error');
flash.addMessage('foo bar error','error');
flash.addMessage('foo info','info');
flash.addMessage('foo success','success');
flash.addMessage('foo custom','custom');

assert.strictEqual(flash.has(), true);
assert.strictEqual(flash.hasMessages(), true);

var errors = flash.get('error');
var errors = flash.getMessages('error');
assert.equal(errors.length, 2);
assert.equal(errors[0], 'foo error');
assert.equal(errors[1], 'foo bar error');

var infos = flash.get('info');
var infos = flash.getMessages('info');
assert.equal(infos.length, 1);
assert.equal(infos[0], 'foo info');

var successes = flash.get('success');
var successes = flash.getMessages('success');
assert.equal(successes.length, 1);
assert.equal(successes[0], 'foo success');

var customs = flash.get('custom');
var customs = flash.getMessages('custom');
assert.equal(customs.length, 1);
assert.equal(customs[0], 'foo custom');

assert.strictEqual(flash.has(), false);
assert.strictEqual(flash.hasMessages(), false);
}
};

Expand Down

0 comments on commit d079aaf

Please sign in to comment.