mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 00:36:16 -04:00
update file shim to use detectFileType.
This commit is contained in:
parent
4add484d2a
commit
aad1bc898e
4 changed files with 25 additions and 4 deletions
|
@ -2,6 +2,7 @@ import assert from "assert";
|
|||
import it from "../assertionHandler";
|
||||
import TestRegister from "../../lib/TestRegister";
|
||||
import File from "../../../src/node/File";
|
||||
import {zip} from "../../../src/node/index";
|
||||
|
||||
TestRegister.addApiTests([
|
||||
it("File: should exist", () => {
|
||||
|
@ -15,6 +16,19 @@ TestRegister.addApiTests([
|
|||
assert(typeof file.lastModified, "number");
|
||||
assert(file.lastModifiedDate instanceof Date);
|
||||
assert.equal(file.size, uint8Array.length);
|
||||
assert.equal(file.type, "text/plain");
|
||||
assert.equal(file.type, "application/unknown");
|
||||
}),
|
||||
|
||||
it("File: Should determine the type of a file", () => {
|
||||
const zipped = zip("hello");
|
||||
const file = new File([zipped.value]);
|
||||
assert(file);
|
||||
assert.strictEqual(file.type, "application/zip");
|
||||
}),
|
||||
|
||||
it("File: unknown type should have a type of application/unknown", () => {
|
||||
const uint8Array = new Uint8Array(Buffer.from("hello"));
|
||||
const file = new File([uint8Array], "sample.txt");
|
||||
assert.strictEqual(file.type, "application/unknown");
|
||||
}),
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue