mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 08:07:17 +08:00
Moved a bunch of tests to QUnit. Added basic Discourse.Site
support to test suite.
This commit is contained in:
15
test/javascripts/models/category_test.js
Normal file
15
test/javascripts/models/category_test.js
Normal file
@ -0,0 +1,15 @@
|
||||
/*global module:true test:true ok:true visit:true expect:true exists:true count:true equal:true */
|
||||
|
||||
module("Discourse.Category");
|
||||
|
||||
test('slugFor', function(){
|
||||
|
||||
var slugFor = function(args, val, text) {
|
||||
equal(Discourse.Category.slugFor(args), val, text);
|
||||
}
|
||||
|
||||
slugFor({slug: 'hello'}, "hello", "It calculates the proper slug for hello");
|
||||
slugFor({id: 123, slug: ''}, "123-category", "It returns id-category for empty strings");
|
||||
slugFor({id: 456}, "456-category", "It returns id-category for undefined slugs");
|
||||
|
||||
});
|
19
test/javascripts/models/composer_test.js
Normal file
19
test/javascripts/models/composer_test.js
Normal file
@ -0,0 +1,19 @@
|
||||
/*global module:true test:true ok:true visit:true expect:true exists:true count:true equal:true */
|
||||
|
||||
module("Discourse.Composer");
|
||||
|
||||
|
||||
test('replyLength', function() {
|
||||
|
||||
var replyLength = function(val, expectedLength, text) {
|
||||
var composer = Discourse.Composer.create({ reply: val });
|
||||
equal(composer.get('replyLength'), expectedLength);
|
||||
};
|
||||
|
||||
replyLength("basic reply", 11, "basic reply length");
|
||||
replyLength(" \nbasic reply\t", 11, "trims whitespaces");
|
||||
replyLength("ba sic\n\nreply", 12, "count only significant whitespaces");
|
||||
replyLength("1[quote=]not counted[/quote]2[quote=]at all[/quote]3", 3, "removes quotes");
|
||||
replyLength("1[quote=]not[quote=]counted[/quote]yay[/quote]2", 2, "handles nested quotes correctly");
|
||||
|
||||
})
|
13
test/javascripts/models/site_test.js
Normal file
13
test/javascripts/models/site_test.js
Normal file
@ -0,0 +1,13 @@
|
||||
/*global module:true test:true ok:true visit:true expect:true exists:true count:true present:true equal:true */
|
||||
|
||||
module("Discourse.Site");
|
||||
|
||||
test('instance', function(){
|
||||
|
||||
var site = Discourse.Site.instance();
|
||||
|
||||
present(site, "We have a current site singleton");
|
||||
present(site.get('categories'), "The instance has a list of categories");
|
||||
present(site.get('flagTypes'), "The instance has a list of flag types");
|
||||
|
||||
});
|
Reference in New Issue
Block a user