-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create twitch proxy tests (#617)
* chore: create twitch proxy tests * log results * bypass broken api key call * restore update function and remove helix tests * chore: set url for gitpod testing * fix: shaun forgets localhost is not secure Co-authored-by: Oliver Eyton-Williams <[email protected]> --------- Co-authored-by: Shaun Hamilton <[email protected]> Co-authored-by: Oliver Eyton-Williams <[email protected]>
- Loading branch information
1 parent
cfb93c7
commit 5be11a9
Showing
5 changed files
with
72 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const config = { | ||
roots: ['./test/'] | ||
roots: ['./test/'], | ||
setupFiles: ['dotenv/config'] | ||
}; | ||
|
||
module.exports = config; |
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,18 @@ | ||
const baseUrl = port => { | ||
if (process.env.DEMO_APPS_DOMAIN === 'localhost') { | ||
const url = new URL('http://localhost'); | ||
url.port = port; | ||
return url; | ||
} | ||
|
||
if (process.env.GITPOD_HOST) { | ||
const url = new URL( | ||
`https://${port}-${process.env.GITPOD_WORKSPACE_ID}.${process.env.GITPOD_WORKSPACE_CLUSTER_HOST}` | ||
); | ||
return url; | ||
} | ||
}; | ||
|
||
module.exports = { | ||
baseUrl | ||
}; |
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,39 @@ | ||
// TODO: Remove once types for Jest are recognized | ||
/* eslint-disable no-undef */ | ||
const portMap = require('../port-map.json'); | ||
const twitchProxyPort = portMap['twitch-proxy']; | ||
const { baseUrl } = require('./jest-utils.js'); | ||
|
||
const BASE_URL = baseUrl(twitchProxyPort); | ||
|
||
describe('kraken api', () => { | ||
it('should return freecodecamp user data', async () => { | ||
const response = await fetch( | ||
new URL('/twitch-api/users/freecodecamp', BASE_URL) | ||
); | ||
const user = await response.json(); | ||
expect(response.status).toBe(200); | ||
expect(user.name).toBe('freecodecamp'); | ||
expect(user.display_name).toBe('FreeCodeCamp'); | ||
}); | ||
|
||
it('should return freecodecamp channel data', async () => { | ||
const response = await fetch( | ||
new URL('/twitch-api/channels/freecodecamp', BASE_URL) | ||
); | ||
const channel = await response.json(); | ||
expect(response.status).toBe(200); | ||
expect(channel.name).toBe('freecodecamp'); | ||
expect(channel.display_name).toBe('FreeCodeCamp'); | ||
expect(channel.url).toBe('https://www.twitch.tv/freecodecamp'); | ||
}); | ||
|
||
it("should return esl_sc2's stream data", async () => { | ||
const response = await fetch( | ||
new URL('/twitch-api/streams/ESL_SC2', BASE_URL) | ||
); | ||
const stream = (await response.json()).stream; | ||
expect(response.status).toBe(200); | ||
expect(stream._id).toBe(23366709968); | ||
}); | ||
}); |