deno.land / x / swarm_gates@0.0.1 / test.js
1234567891011121314151617181920212223242526272829303132import SwarmGates from "./mod.ts";import { testing,} from "./deps.js";
const text_data = "SwarmGates";const host = "https://swarm-gateways.net";
const gate = new SwarmGates(host);let hash;
Deno.test("Uploads raw data correctly", async () => { hash = await gate.upload(new TextEncoder().encode((text_data))); testing.assert(hash, "Hash for file wasn't retrieved correctly");
await testing.assertThrowsAsync(async () => { await gate.upload(new Uint8Array()); });});
Deno.test("Downloads raw data correctly", async () => { const data = await gate.download(hash);
testing.assertEquals(new TextDecoder().decode(data), text_data);});
Deno.test("Checks availability", async () => { const data = await gate.isAvailable();
testing.assert(data);});
Version Info