2013-03-02 01:45:25 +08:00
|
|
|
/*global waitsFor:true expect:true describe:true beforeEach:true it:true */
|
|
|
|
|
2013-03-01 06:58:13 +08:00
|
|
|
describe("Discourse.Composer", function() {
|
|
|
|
|
|
|
|
describe("replyLength", function() {
|
|
|
|
|
|
|
|
it("returns the length of a basic reply", function() {
|
|
|
|
var composer = Discourse.Composer.create({ reply: "basic reply" });
|
|
|
|
expect(composer.get('replyLength')).toBe(11);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("trims whitespaces", function() {
|
2013-03-13 06:54:29 +08:00
|
|
|
var composer = Discourse.Composer.create({ reply: " \nbasic reply\t" });
|
2013-03-01 06:58:13 +08:00
|
|
|
expect(composer.get('replyLength')).toBe(11);
|
|
|
|
});
|
|
|
|
|
2013-03-13 06:54:29 +08:00
|
|
|
it("count only significant whitespaces", function() {
|
|
|
|
// this will count the '\n' only once
|
|
|
|
var composer = Discourse.Composer.create({ reply: "ba sic\n\nreply" });
|
|
|
|
expect(composer.get('replyLength')).toBe(12);
|
|
|
|
});
|
|
|
|
|
2013-03-01 06:58:13 +08:00
|
|
|
it("removes quotes", function() {
|
|
|
|
var composer = Discourse.Composer.create({ reply: "1[quote=]not counted[/quote]2[quote=]at all[/quote]3" });
|
|
|
|
expect(composer.get('replyLength')).toBe(3);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("handles nested quotes correctly", function() {
|
|
|
|
var composer = Discourse.Composer.create({ reply: "1[quote=]not[quote=]counted[/quote]yay[/quote]2" });
|
|
|
|
expect(composer.get('replyLength')).toBe(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|