aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.test.ts22
-rw-r--r--src/scraper.test.ts18
2 files changed, 40 insertions, 0 deletions
diff --git a/src/app.test.ts b/src/app.test.ts
index 59ed352..94bf205 100644
--- a/src/app.test.ts
+++ b/src/app.test.ts
@@ -92,6 +92,28 @@ describe("sidebar fragment", () => {
});
});
+describe("blob view", () => {
+ const blob = {
+ repo: { owner: "justrajdeep", name: "fonts" },
+ branch: "master",
+ path: "Times New Roman.ttf",
+ language: null,
+ size: "815 KB",
+ image: false,
+ textLines: null,
+ htmlLines: null,
+ htmlContent: null,
+ };
+
+ // GitHub previews neither the text nor the bytes of most binary files.
+ it("should offer the raw file when there is nothing to display", () => {
+ const html = eta.render("blob.eta", blob);
+
+ assert.match(html, /This file cannot be displayed\./);
+ assert.match(html, /href="\/justrajdeep\/fonts\/raw\/master\/Times New Roman.ttf">View raw/);
+ });
+});
+
describe("redirects to GitHub", () => {
// An HTTP redirect would be caught by the extension's declarativeNetRequest
// rules and bounced straight back here.
diff --git a/src/scraper.test.ts b/src/scraper.test.ts
index 24fdfc0..836235e 100644
--- a/src/scraper.test.ts
+++ b/src/scraper.test.ts
@@ -332,6 +332,24 @@ describe("GitHub scraper", () => {
assert.strictEqual(data.htmlLines, null);
assert.strictEqual(data.htmlContent, null);
});
+
+ // A binary file GitHub has no preview for: no content of any kind, and the
+ // path exercises escaping of a space.
+ it("should support an unpreviewable binary file", async () => {
+ const data = await getGitHubBlob("justrajdeep", "fonts", "master", "Times New Roman.ttf");
+
+ assert.strictEqual(data.repo.owner, "justrajdeep");
+ assert.strictEqual(data.repo.name, "fonts");
+ assert.strictEqual(data.branch, "master");
+ assert.strictEqual(data.path, "Times New Roman.ttf");
+
+ assert.strictEqual(data.size, "815 KB");
+ assert.strictEqual(data.language, null);
+ assert.strictEqual(data.image, false);
+ assert.strictEqual(data.textLines, null);
+ assert.strictEqual(data.htmlLines, null);
+ assert.strictEqual(data.htmlContent, null);
+ });
});
describe("owner pages", () => {