Moved a bunch of tests to QUnit. Added basic Discourse.Site support to test suite.

This commit is contained in:
Robin Ward
2013-06-17 11:38:30 -04:00
parent 2174c0d661
commit 797b99db7c
14 changed files with 112 additions and 259 deletions

View File

@ -1,21 +0,0 @@
/*global waitsFor:true expect:true describe:true beforeEach:true it:true spyOn:true */
describe("Discourse.Category", function() {
describe("slugFor", function() {
it("returns the slug when it exists", function() {
expect(Discourse.Category.slugFor({ slug: 'hello' })).toBe("hello");
});
it("returns id-category when slug is an empty string", function() {
expect(Discourse.Category.slugFor({ id: 123, slug: '' })).toBe("123-category");
});
it("returns id-category without a slug", function() {
expect(Discourse.Category.slugFor({ id: 456 })).toBe("456-category");
});
});
});

View File

@ -1,35 +0,0 @@
/*global waitsFor:true expect:true describe:true beforeEach:true it:true */
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() {
var composer = Discourse.Composer.create({ reply: " \nbasic reply\t" });
expect(composer.get('replyLength')).toBe(11);
});
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);
});
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);
});
});
});