Fix length check of pm body; refactor composer length and title length validation

This commit is contained in:
Neil Lalonde
2013-06-20 12:33:21 -04:00
parent 9f3d5b9f1e
commit 94853f0295
4 changed files with 69 additions and 23 deletions

View File

@ -16,4 +16,25 @@ test('replyLength', function() {
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");
})
});
test('missingReplyCharacters', function() {
var missingReplyCharacters = function(val, isPM, expected, message) {
var composer = Discourse.Composer.create({ reply: val, creatingPrivateMessage: isPM });
equal(composer.get('missingReplyCharacters'), expected, message);
}
missingReplyCharacters('hi', false, Discourse.SiteSettings.min_post_length - 2, 'too short public post');
missingReplyCharacters('hi', true, Discourse.SiteSettings.min_private_message_post_length - 2, 'too short private message');
});
test('missingTitleCharacters', function() {
var missingTitleCharacters = function(val, isPM, expected, message) {
var composer = Discourse.Composer.create({ title: val, creatingPrivateMessage: isPM });
equal(composer.get('missingTitleCharacters'), expected, message);
}
missingTitleCharacters('hi', false, Discourse.SiteSettings.min_topic_title_length - 2, 'too short post title');
missingTitleCharacters('z', true, Discourse.SiteSettings.min_private_message_title_length - 1, 'too short pm title');
});