mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
Moved JSHint into Qunit suite. It's much harder to forget about now!
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
/*global md5:true */
|
||||
|
||||
module("Discourse.BBCode");
|
||||
|
||||
var format = function(input, expected, text) {
|
||||
// testing 1 2 3
|
||||
equal(Discourse.BBCode.format(input, {lookupAvatar: false}), expected, text);
|
||||
}
|
||||
};
|
||||
|
||||
test('basic bbcode', function() {
|
||||
format("[b]strong[/b]", "<span class='bbcode-b'>strong</span>", "bolds text");
|
||||
@ -50,7 +50,7 @@ test("quotes", function() {
|
||||
|
||||
var formatQuote = function(val, expected, text) {
|
||||
equal(Discourse.BBCode.buildQuoteBBCode(post, val), expected, text);
|
||||
}
|
||||
};
|
||||
|
||||
formatQuote(undefined, "", "empty string for undefined content");
|
||||
formatQuote(null, "", "empty string for null content");
|
||||
|
@ -37,9 +37,10 @@ module("Discourse.ClickTrack", {
|
||||
|
||||
var track = Discourse.ClickTrack.trackClick;
|
||||
|
||||
// test
|
||||
var generateClickEventOn = function(selector) {
|
||||
return $.Event("click", { currentTarget: $(selector)[0] });
|
||||
}
|
||||
};
|
||||
|
||||
test("does not track clicks on lightboxes", function() {
|
||||
var clickEvent = generateClickEventOn('.lightbox');
|
||||
@ -57,11 +58,11 @@ test("it calls preventDefault when clicking on an a", function() {
|
||||
});
|
||||
|
||||
test("does not track clicks on back buttons", function() {
|
||||
ok(track(generateClickEventOn('.back')))
|
||||
ok(track(generateClickEventOn('.back')));
|
||||
});
|
||||
|
||||
test("does not track clicks on quote buttons", function() {
|
||||
ok(track(generateClickEventOn('.quote-other-topic')))
|
||||
ok(track(generateClickEventOn('.quote-other-topic')));
|
||||
});
|
||||
|
||||
test("removes the href and put it as a data attribute", function() {
|
||||
@ -99,7 +100,7 @@ test("updates badge counts correctly", function() {
|
||||
});
|
||||
|
||||
var trackRightClick = function() {
|
||||
var clickEvent = generateClickEventOn('a')
|
||||
var clickEvent = generateClickEventOn('a');
|
||||
clickEvent.which = 3;
|
||||
return track(clickEvent);
|
||||
};
|
||||
|
@ -27,15 +27,15 @@ test("formating medium length dates", function() {
|
||||
format = "medium";
|
||||
var strip = function(html){
|
||||
return $(html).text();
|
||||
}
|
||||
};
|
||||
|
||||
var shortDate = function(days){
|
||||
return moment().subtract('days', days).format('D MMM');
|
||||
}
|
||||
};
|
||||
|
||||
var shortDateYear = function(days){
|
||||
return moment().subtract('days', days).format('D MMM, YYYY');
|
||||
}
|
||||
};
|
||||
|
||||
leaveAgo = true;
|
||||
equal(strip(formatMins(1.4)), "1 min ago");
|
||||
|
@ -12,11 +12,10 @@ var cooked = function(input, expected, text) {
|
||||
|
||||
var cookedOptions = function(input, opts, expected, text) {
|
||||
equal(Discourse.Markdown.cook(input, opts), expected, text);
|
||||
}
|
||||
};
|
||||
|
||||
test("basic cooking", function() {
|
||||
cooked("hello", "<p>hello</p>", "surrounds text with paragraphs");
|
||||
|
||||
});
|
||||
|
||||
test("Line Breaks", function() {
|
||||
@ -29,10 +28,10 @@ test("Line Breaks", function() {
|
||||
cookedOptions(input,
|
||||
{traditional_markdown_linebreaks: true},
|
||||
traditionalOutput,
|
||||
"It supports traditional markdown via an option")
|
||||
"It supports traditional markdown via an option");
|
||||
|
||||
Discourse.SiteSettings.traditional_markdown_linebreaks = true;
|
||||
cooked(input, traditionalOutput, "It supports traditional markdown via a Site Setting")
|
||||
cooked(input, traditionalOutput, "It supports traditional markdown via a Site Setting");
|
||||
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user