2019-09-09 08:10:07 +00:00
|
|
|
//import * as assert from "assert";
|
|
|
|
//const assert = require('assert');
|
2019-09-09 12:20:59 +00:00
|
|
|
import * as assert from "assert";
|
|
|
|
import { mimeOrDefault, asset } from "../src/github";
|
2019-09-09 08:10:07 +00:00
|
|
|
|
2019-09-09 12:20:59 +00:00
|
|
|
describe("github", () => {
|
|
|
|
describe("mimeOrDefault", () => {
|
|
|
|
it("returns a specific mime for common path", async () => {
|
|
|
|
assert.equal(mimeOrDefault("foo.tar.gz"), "application/gzip");
|
|
|
|
});
|
|
|
|
it("returns default mime for uncommon path", async () => {
|
|
|
|
assert.equal(mimeOrDefault("foo.uncommon"), "application/octet-stream");
|
|
|
|
});
|
|
|
|
});
|
2019-09-09 08:10:07 +00:00
|
|
|
|
2019-09-09 12:20:59 +00:00
|
|
|
describe("asset", () => {
|
|
|
|
it("derives asset info from a path", async () => {
|
2021-08-08 04:28:01 +00:00
|
|
|
const { name, mime, size, data } = asset("tests/data/foo/bar.txt");
|
2019-09-09 12:20:59 +00:00
|
|
|
assert.equal(name, "bar.txt");
|
|
|
|
assert.equal(mime, "text/plain");
|
|
|
|
assert.equal(size, 10);
|
2021-08-08 04:28:01 +00:00
|
|
|
assert.equal(data.toString(), "release me");
|
2019-09-09 12:20:59 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|