-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
186 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
transform: { '^.+\\.ts?$': 'ts-jest' }, | ||
testEnvironment: 'node', | ||
testRegex: '/tests/.*\\.(test|spec)?\\.(ts|tsx)$', | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
roots: ['<rootDir>/src'], | ||
moduleNameMapper: { | ||
'@/(.*)': '<rootDir>/src/$1' | ||
} | ||
} |
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
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,20 @@ | ||
import app from '@/index' | ||
|
||
describe('GET /test/:videoId', () => { | ||
it('should return 200', async () => { | ||
const res = await app.request('/test/7332187682480590112', { | ||
method: 'GET' | ||
}) | ||
|
||
expect(res.status).toBe(200) | ||
}) | ||
|
||
it('should return 500', async () => { | ||
const res = await app.request('/test/123', { | ||
method: 'GET' | ||
}) | ||
|
||
expect(res.status).toBe(500) | ||
expect(await res.text()).toBe('Could not parse video info') | ||
}) | ||
}) |
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,53 @@ | ||
import app from '@/index' | ||
|
||
describe('GET /@i/photo/:videoId', () => { | ||
it('should return 200', async () => { | ||
const res = await app.request('/@i/photo/7335753580093164833', { | ||
method: 'GET', | ||
headers: { | ||
'User-Agent': 'Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)' | ||
} | ||
}) | ||
|
||
expect(res.status).toBe(200) | ||
}) | ||
|
||
// no discord user agent, redirects | ||
it('should return 302', async () => { | ||
const res = await app.request('/@i/photo/7335753580093164833', { | ||
method: 'GET' | ||
}) | ||
|
||
expect(res.status).toBe(302) | ||
}) | ||
|
||
it('should return 500', async () => { | ||
const res = await app.request('/@i/photo/123', { | ||
method: 'GET', | ||
headers: { | ||
'User-Agent': 'Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)' | ||
} | ||
}) | ||
|
||
expect(res.status).toBe(500) | ||
expect(await res.text()).toContain('An error occurred while trying to fetch the video. Please try again later.') | ||
}) | ||
}) | ||
|
||
describe('GET /generate/image/:videoId', () => { | ||
it('should return 302', async () => { | ||
const res = await app.request('/generate/image/7335753580093164833', { | ||
method: 'GET' | ||
}) | ||
|
||
expect(res.status).toBe(302) | ||
}) | ||
|
||
it('should return 500', async () => { | ||
const res = await app.request('/generate/image/123', { | ||
method: 'GET' | ||
}) | ||
|
||
expect(res.status).toBe(500) | ||
}) | ||
}) |
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,66 @@ | ||
import app from '@/index' | ||
|
||
describe('GET /@i/video/:videoId', () => { | ||
it('should return 200', async () => { | ||
const res = await app.request('/@pr4yforgabs/video/7332187682480590112', { | ||
method: 'GET', | ||
headers: { | ||
'User-Agent': 'Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)' | ||
} | ||
}) | ||
|
||
expect(res.status).toBe(200) | ||
}) | ||
|
||
// no discord user agent, redirects | ||
it('should return 302', async () => { | ||
const res = await app.request('/@pr4yforgabs/video/7332187682480590112', { | ||
method: 'GET' | ||
}) | ||
|
||
expect(res.status).toBe(302) | ||
}) | ||
|
||
it('should return 500', async () => { | ||
const res = await app.request('/@i/video/123', { | ||
method: 'GET', | ||
headers: { | ||
'User-Agent': 'Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)' | ||
} | ||
}) | ||
|
||
expect(res.status).toBe(500) | ||
expect(await res.text()).toContain('An error occurred while trying to fetch the video. Please try again later.') | ||
}) | ||
}) | ||
|
||
describe('GET /t/:videoId', () => { | ||
it('should return 200', async () => { | ||
const res = await app.request('/t/ZPRKrbUB1', { | ||
method: 'GET', | ||
headers: { | ||
'User-Agent': 'Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)' | ||
} | ||
}) | ||
|
||
expect(res.status).toBe(200) | ||
}) | ||
}) | ||
|
||
describe('GET /generate/video/:videoId', () => { | ||
it('should return 302', async () => { | ||
const res = await app.request('/generate/video/7332187682480590112', { | ||
method: 'GET' | ||
}) | ||
|
||
expect(res.status).toBe(302) | ||
}) | ||
|
||
it('should return 500', async () => { | ||
const res = await app.request('/generate/video/123', { | ||
method: 'GET' | ||
}) | ||
|
||
expect(res.status).toBe(500) | ||
}) | ||
}) |
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