A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v4 128 lines 3.7 kB view raw
1import { describe, it } from "@std/testing/bdd"; 2import { expect } from "@std/expect"; 3 4import { testWeb } from "@tests/common/index.ts"; 5 6describe("components/output/bytes/s3", () => { 7 it("ready returns false when no bucket is configured", async () => { 8 const result = await testWeb(async () => { 9 const mod = await import("~/components/output/bytes/s3/element.js"); 10 const output = new mod.CLASS(); 11 document.body.append(output); 12 return output.ready(); 13 }); 14 15 expect(result).toBe(false); 16 }); 17 18 it("bucket returns undefined initially", async () => { 19 const result = await testWeb(async () => { 20 const mod = await import("~/components/output/bytes/s3/element.js"); 21 const output = new mod.CLASS(); 22 document.body.append(output); 23 return output.bucket() ?? null; 24 }); 25 26 expect(result).toBe(null); 27 }); 28 29 it("getBucket returns undefined when no bucket is stored", async () => { 30 const result = await testWeb(async () => { 31 const mod = await import("~/components/output/bytes/s3/element.js"); 32 const output = new mod.CLASS(); 33 document.body.append(output); 34 return (await output.getBucket()) ?? null; 35 }); 36 37 expect(result).toBe(null); 38 }); 39 40 it("setBucket updates the bucket signal", async () => { 41 const result = await testWeb(async () => { 42 const mod = await import("~/components/output/bytes/s3/element.js"); 43 const output = new mod.CLASS(); 44 document.body.append(output); 45 46 await output.setBucket({ 47 accessKey: "myKey", 48 secretKey: "mySecret", 49 host: "s3.amazonaws.com", 50 bucketName: "my-bucket", 51 path: "/", 52 region: "us-east-1", 53 }); 54 55 return output.bucket(); 56 }); 57 58 expect(result?.bucketName).toBe("my-bucket"); 59 expect(result?.accessKey).toBe("myKey"); 60 }); 61 62 it("ready returns true after setBucket when online", async () => { 63 const result = await testWeb(async () => { 64 const mod = await import("~/components/output/bytes/s3/element.js"); 65 const output = new mod.CLASS(); 66 document.body.append(output); 67 68 await output.setBucket({ 69 accessKey: "myKey", 70 secretKey: "mySecret", 71 host: "s3.amazonaws.com", 72 bucketName: "my-bucket", 73 path: "/", 74 region: "us-east-1", 75 }); 76 77 // ready = bucket !== undefined && isOnline 78 // isOnline follows navigator.onLine which is true in headless Chromium 79 return output.ready(); 80 }); 81 82 expect(result).toBe(true); 83 }); 84 85 it("unsetBucket clears the bucket signal", async () => { 86 const result = await testWeb(async () => { 87 const mod = await import("~/components/output/bytes/s3/element.js"); 88 const output = new mod.CLASS(); 89 document.body.append(output); 90 91 await output.setBucket({ 92 accessKey: "myKey", 93 secretKey: "mySecret", 94 host: "s3.amazonaws.com", 95 bucketName: "my-bucket", 96 path: "/", 97 region: "us-east-1", 98 }); 99 100 await output.unsetBucket(); 101 return output.bucket() ?? null; 102 }); 103 104 expect(result).toBe(null); 105 }); 106 107 it("ready returns false after unsetBucket", async () => { 108 const result = await testWeb(async () => { 109 const mod = await import("~/components/output/bytes/s3/element.js"); 110 const output = new mod.CLASS(); 111 document.body.append(output); 112 113 await output.setBucket({ 114 accessKey: "myKey", 115 secretKey: "mySecret", 116 host: "s3.amazonaws.com", 117 bucketName: "my-bucket", 118 path: "/", 119 region: "us-east-1", 120 }); 121 122 await output.unsetBucket(); 123 return output.ready(); 124 }); 125 126 expect(result).toBe(false); 127 }); 128});