github.test.ts 855 B

1234567891011121314151617181920212223242526
  1. //import * as assert from "assert";
  2. //const assert = require('assert');
  3. import * as assert from "assert";
  4. import { mimeOrDefault, asset } from "../src/github";
  5. describe("github", () => {
  6. describe("mimeOrDefault", () => {
  7. it("returns a specific mime for common path", async () => {
  8. assert.equal(mimeOrDefault("foo.tar.gz"), "application/gzip");
  9. });
  10. it("returns default mime for uncommon path", async () => {
  11. assert.equal(mimeOrDefault("foo.uncommon"), "application/octet-stream");
  12. });
  13. });
  14. describe("asset", () => {
  15. it("derives asset info from a path", async () => {
  16. const { name, mime, size, data } = asset("tests/data/foo/bar.txt");
  17. assert.equal(name, "bar.txt");
  18. assert.equal(mime, "text/plain");
  19. assert.equal(size, 10);
  20. assert.equal(data.toString(), "release me");
  21. });
  22. });
  23. });