This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
886 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# worker-playground | ||
|
||
This is a playground to confirm some function implement are safe in worker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
dependsOn: | ||
- karbon-utils | ||
|
||
tasks: | ||
test: | ||
command: vitest | ||
inputs: | ||
- tests/**/* | ||
- vitest.config.ts | ||
- wrangler.toml | ||
deps: | ||
- ^:build | ||
test-run: | ||
extends: test | ||
args: run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "worker-playground", | ||
"private": true, | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"test": "moon run test --" | ||
}, | ||
"dependencies": { | ||
"@storipress/karbon-utils": "workspace:^" | ||
}, | ||
"devDependencies": { | ||
"@cloudflare/vitest-pool-workers": "0.2.6", | ||
"@cloudflare/workers-types": "^4.20240502.0", | ||
"@tsconfig/node18": "^18.2.4", | ||
"vitest": "1.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Buffer } from 'node:buffer' | ||
import { describe, expect } from 'vitest' | ||
import { fc, it } from '@fast-check/vitest' | ||
import { base64ToUint8Array, textToUint8Array, uint8ArrayToBase64, uint8ArrayToText } from '@storipress/karbon-utils' | ||
|
||
describe('textToUint8Array & uint8ArrayToText', () => { | ||
it.prop({ text: fc.string() })('can convert text to and from uint8array', ({ text }) => { | ||
const array = textToUint8Array(text) | ||
const result = uint8ArrayToText(array) | ||
expect(result).toBe(text) | ||
}) | ||
}) | ||
|
||
describe('base64ToUint8Array', () => { | ||
it.prop({ s: fc.string() })('can convert base64 to Uint8Array', ({ s }) => { | ||
const base64 = Buffer.from(s).toString('base64') | ||
expect(Buffer.from(base64ToUint8Array(base64)).toString()).toEqual(s) | ||
}) | ||
}) | ||
|
||
describe('base64ToUint8Array & uint8ArrayToBase64', () => { | ||
it.prop({ s: fc.string() })('can convert base64 string from and to uint8array', ({ s }) => { | ||
const base64 = Buffer.from(s).toString('base64') | ||
expect(uint8ArrayToBase64(base64ToUint8Array(base64))).toEqual(base64) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "@tsconfig/node18", | ||
"compilerOptions": { | ||
"lib": ["esnext"], | ||
"module": "esnext", | ||
"moduleResolution": "bundler", | ||
"types": ["@cloudflare/workers-types/experimental", "@cloudflare/vitest-pool-workers"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config' | ||
|
||
export default defineWorkersConfig({ | ||
test: { | ||
poolOptions: { | ||
workers: { | ||
wrangler: { configPath: './wrangler.toml' }, | ||
}, | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
compatibility_date = '2024-01-01' | ||
compatibility_flags = ['nodejs_compat'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { defineWorkspace } from 'vitest/config' | ||
|
||
export default defineWorkspace(['packages/*/vitest.config.ts']) | ||
export default defineWorkspace(['packages/*/vitest.config.ts', '!packages/worker-playground/vitest.config.ts']) |
Oops, something went wrong.