-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from maretol/add-capture-images
Add capture images
- Loading branch information
Showing
12 changed files
with
403 additions
and
272 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 |
---|---|---|
@@ -1,25 +1,95 @@ | ||
// test/index.spec.ts | ||
import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test'; | ||
import { describe, it, expect } from 'vitest'; | ||
import worker from '../src/index'; | ||
import { describe, it, expect } from 'vitest' | ||
import { getPOption } from '../src/parse' | ||
|
||
// For now, you'll need to do something like this to get a correctly-typed | ||
// `Request` to pass to `worker.fetch()`. | ||
const IncomingRequest = Request<unknown, IncomingRequestCfProperties>; | ||
|
||
describe('Hello World worker', () => { | ||
it('responds with Hello World! (unit style)', async () => { | ||
const request = new IncomingRequest('http://example.com'); | ||
// Create an empty context to pass to `worker.fetch()`. | ||
const ctx = createExecutionContext(); | ||
const response = await worker.fetch(request, env, ctx); | ||
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions | ||
await waitOnExecutionContext(ctx); | ||
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); | ||
}); | ||
|
||
it('responds with Hello World! (integration style)', async () => { | ||
const response = await SELF.fetch('https://example.com'); | ||
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); | ||
}); | ||
}); | ||
describe('parse_getPOptionのテスト', () => { | ||
it('通常テキストの場合', () => { | ||
const text = 'test text' | ||
const result = getPOption(text) | ||
expect(result).toBe('normal') | ||
}) | ||
it('空文字の場合', () => { | ||
const text = '' | ||
const result = getPOption(text) | ||
expect(result).toBe('empty') | ||
}) | ||
it('画像の場合', () => { | ||
const text = 'https://r2.maretol.xyz/test.png' | ||
const result = getPOption(text) | ||
expect(result).toBe('image') | ||
}) | ||
it('写真の場合', () => { | ||
const text = 'https://photos.maretol.xyz/test.jpg' | ||
const result = getPOption(text) | ||
expect(result).toBe('photo') | ||
}) | ||
it('写真(スクリーンショット)の場合', () => { | ||
const text = 'https://capture.maretol.xyz/test.jpg' | ||
const result = getPOption(text) | ||
expect(result).toBe('photo') | ||
}) | ||
it('写真でサブテキストがあった場合', () => { | ||
const text = 'https://photos.maretol.xyz/test.jpg@@subtext_key::subtext_value@@subtext::サブテキスト' | ||
const result = getPOption(text) | ||
expect(result).toBe('photo') | ||
}) | ||
it('漫画リンクの場合', () => { | ||
const text = 'https://www.maretol.xyz/comics/test' | ||
const result = getPOption(text) | ||
expect(result).toBe('comic') | ||
}) | ||
it('YouTubeリンクの場合', () => { | ||
const text = 'https://www.youtube.com/watch?v=test' | ||
const result = getPOption(text) | ||
expect(result).toBe('youtube') | ||
}) | ||
it('Youtube短縮URLリンクの場合', () => { | ||
const text = 'https://youtu.be/test' | ||
const result = getPOption(text) | ||
expect(result).toBe('youtube') | ||
}) | ||
it('Twitterリンクの場合', () => { | ||
const text = 'https://twitter.com/test' | ||
const result = getPOption(text) | ||
expect(result).toBe('twitter') | ||
}) | ||
it('Twitterリンク(wwwあり)の場合', () => { | ||
const text = 'https://www.twitter.com/test' | ||
const result = getPOption(text) | ||
expect(result).toBe('twitter') | ||
}) | ||
it('Xリンクの場合', () => { | ||
const text = 'https://x.com/test' | ||
const result = getPOption(text) | ||
expect(result).toBe('twitter') | ||
}) | ||
it('Amazonリンクの場合', () => { | ||
const text = 'https://www.amazon.co.jp/test' | ||
const result = getPOption(text) | ||
expect(result).toBe('amazon') | ||
}) | ||
it('Amazon短縮URLリンクの場合', () => { | ||
const text = 'https://amzn.to/test' | ||
const result = getPOption(text) | ||
expect(result).toBe('amazon') | ||
}) | ||
it('ブログリンクの場合', () => { | ||
const text = 'https://www.maretol.xyz/blog/test' | ||
const result = getPOption(text) | ||
expect(result).toBe('blog') | ||
}) | ||
it('artifactリンクの場合', () => { | ||
const text = 'https://www.maretol.xyz/artifacts/test' | ||
const result = getPOption(text) | ||
expect(result).toBe('artifact') | ||
}) | ||
it('その他のURLの場合', () => { | ||
const text = 'https://example.com' | ||
const result = getPOption(text) | ||
expect(result).toBe('url') | ||
}) | ||
it('コマンド入力の場合', () => { | ||
const text = '/test_command' | ||
const result = getPOption(text) | ||
expect(result).toBe('test_command') | ||
}) | ||
}) |
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
Oops, something went wrong.