import { describe, it, expect } from "bun:test"; import { mkdirSync, existsSync, readFileSync, writeFileSync } from "node:fs"; describe("mkdirSync", () => { it("should create a directory", () => { const tempdir = `/tmp/fs.test.js/${Date.now()}/1234/hi`; expect(existsSync(tempdir)).toBe(false); expect(tempdir.includes(mkdirSync(tempdir, { recursive: true }))).toBe( true ); expect(existsSync(tempdir)).toBe(true); }); }); describe("readFileSync", () => { it("works", () => { const text = readFileSync(import.meta.dir + "/readFileSync.txt", "utf8"); expect(text).toBe("File read successfully"); }); it("returning Uint8Array works", () => { const text = readFileSync(import.meta.dir + "/readFileSync.txt"); const encoded = [ 70, 105, 108, 101, 32, 114, 101, 97, 100, 32, 115, 117, 99, 99, 101, 115, 115, 102, 117, 108, 108, 121, ]; for (let i = 0; i < encoded.length; i++) { expect(text[i]).toBe(encoded[i]); } }); }); describe("writeFileSync", () => { it("works", () => { const path = `/tmp/${Date.now()}.writeFileSync.txt`; writeFileSync(path, "File written successfully", "utf8"); expect(readFileSync(path, "utf8")).toBe("File written successfully"); }); it("returning Uint8Array works", () => { const buffer = new Uint8Array([ 70, 105, 108, 101, 32, 119, 114, 105, 116, 116, 101, 110, 32, 115, 117, 99, 99, 101, 115, 115, 102, 117, 108, 108, 121, ]); const path = `/tmp/${Date.now()}.blob.writeFileSync.txt`; writeFileSync(path, buffer); const out = readFileSync(path); for (let i = 0; i < buffer.length; i++) { expect(buffer[i]).toBe(out[i]); } }); it("returning ArrayBuffer works", () => { const buffer = new Uint8Array([ 70, 105, 108, 101, 32, 119, 114, 105, 116, 116, 101, 110, 32, 115, 117, 99, 99, 101, 115, 115, 102, 117, 108, 108, 121, ]); const path = `/tmp/${Date.now()}.blob2.writeFileSync.txt`; writeFileSync(path, buffer.buffer); const out = readFileSync(path); for (let i = 0; i < buffer.length; i++) { expect(buffer[i]).toBe(out[i]); } }); }); hris/social-feed Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/examples/docs/public/make-scrollable-code-focusable.js (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2021-10-14Expose Vue component names for devtools (#1512)Gravatar Levi 3-3/+10
2021-10-14Fix type error in blog-multiple-authors example (#1553)Gravatar Yoshiaki Togami 4-4/+9
2021-10-14Add Vercel sponsorship logo (#1555)Gravatar Drew Powers 8-48/+60
2021-10-14Include pnpm example on "Installation" page (#1554)Gravatar Henrique Borges 1-0/+5
2021-10-14Added descriptions to docs pages (#1550)Gravatar AsyncBanana 22-8/+28
2021-10-14Only run `.github/workflows/stats.yml` locally, not on forks (#1549)Gravatar Caleb Jasik 1-0/+1
2021-10-14[ci] collect statsGravatar FredKSchott 1-0/+1
2021-10-13Add Community Themes and separate Featured Theme (#1543)Gravatar Mark Teekman 2-8/+30
2021-10-13Change publish date el to be more accessible (#1522)Gravatar AsyncBanana 2-2/+2
2021-10-13[ci] yarn formatGravatar matthewp 1-1/+1
2021-10-13docs: unify concepts in Spanish version (#1545)Gravatar Jorge del Casar 6-11/+11
2021-10-13[ci] yarn formatGravatar matthewp 1-1/+1