mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 16:42:46 +08:00
update front-end specs
This commit is contained in:
parent
b94d26d798
commit
360695bb0a
|
@ -20,6 +20,7 @@ module("Discourse.ClickTrack", {
|
||||||
' <a id="inside-onebox-forced" class="track-link" href="http://www.google.com">google.com<span class="badge">1</span></a>',
|
' <a id="inside-onebox-forced" class="track-link" href="http://www.google.com">google.com<span class="badge">1</span></a>',
|
||||||
' </div>',
|
' </div>',
|
||||||
' <a id="same-site" href="http://discuss.domain.com">forum</a>',
|
' <a id="same-site" href="http://discuss.domain.com">forum</a>',
|
||||||
|
' <a class="attachment" href="http://discuss.domain.com/uploads/default/1234/1532357280.txt">log.txt</a>',
|
||||||
' </article>',
|
' </article>',
|
||||||
'</div>'].join("\n"));
|
'</div>'].join("\n"));
|
||||||
},
|
},
|
||||||
|
@ -156,6 +157,13 @@ test("tracks via AJAX if we're on the same site", function() {
|
||||||
ok(Discourse.URL.routeTo.calledOnce);
|
ok(Discourse.URL.routeTo.calledOnce);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("does not track via AJAX for attachments", function() {
|
||||||
|
this.stub(Discourse.URL, "routeTo");
|
||||||
|
this.stub(Discourse.URL, "origin").returns("http://discuss.domain.com");
|
||||||
|
|
||||||
|
ok(!track(generateClickEventOn('.attachment')));
|
||||||
|
ok(Discourse.URL.redirectTo.calledOnce);
|
||||||
|
});
|
||||||
|
|
||||||
test("tracks custom urls when opening in another window", function() {
|
test("tracks custom urls when opening in another window", function() {
|
||||||
var clickEvent = generateClickEventOn('a');
|
var clickEvent = generateClickEventOn('a');
|
||||||
|
|
|
@ -7,7 +7,6 @@ test("emailValid", function() {
|
||||||
ok(utils.emailValid('bob@EXAMPLE.com'), "allows upper case in the email domain");
|
ok(utils.emailValid('bob@EXAMPLE.com'), "allows upper case in the email domain");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var validUpload = utils.validateFilesForUpload;
|
var validUpload = utils.validateFilesForUpload;
|
||||||
|
|
||||||
test("validateFilesForUpload", function() {
|
test("validateFilesForUpload", function() {
|
||||||
|
@ -51,9 +50,9 @@ test("prevents files that are too big from being uploaded", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var dummyBlob = function() {
|
var dummyBlob = function() {
|
||||||
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
|
var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
|
||||||
if (window.BlobBuilder) {
|
if (BlobBuilder) {
|
||||||
var bb = new window.BlobBuilder();
|
var bb = new BlobBuilder();
|
||||||
bb.append([1]);
|
bb.append([1]);
|
||||||
return bb.getBlob("image/png");
|
return bb.getBlob("image/png");
|
||||||
} else {
|
} else {
|
||||||
|
@ -85,3 +84,28 @@ test("isAuthorizedUpload", function() {
|
||||||
ok(!isAuthorized("image.txt"));
|
ok(!isAuthorized("image.txt"));
|
||||||
ok(!isAuthorized(""));
|
ok(!isAuthorized(""));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var getUploadMarkdown = function(filename) {
|
||||||
|
return utils.getUploadMarkdown({
|
||||||
|
original_filename: filename,
|
||||||
|
width: 100,
|
||||||
|
height: 200,
|
||||||
|
url: "/upload/123/abcdef.ext"
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
test("getUploadMarkdown", function() {
|
||||||
|
ok(getUploadMarkdown("lolcat.gif") === '<img src="/upload/123/abcdef.ext" width="100" height="200">');
|
||||||
|
ok(getUploadMarkdown("important.txt") === '<a class="attachment" href="/upload/123/abcdef.ext">important.txt</a>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test("isAnImage", function() {
|
||||||
|
_.each(["png", "jpg", "jpeg", "bmp", "gif", "tif"], function(extension) {
|
||||||
|
var image = "image." + extension;
|
||||||
|
ok(utils.isAnImage(image));
|
||||||
|
ok(utils.isAnImage("http://foo.bar/path/to/" + image));
|
||||||
|
});
|
||||||
|
ok(!utils.isAnImage("file.txt"));
|
||||||
|
ok(!utils.isAnImage("http://foo.bar/path/to/file.txt"));
|
||||||
|
ok(!utils.isAnImage(""));
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user