-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for @jupyterhub/binderhub-client
- Re-adds #1741, but with [Jest](https://jestjs.io/) based unit tests. Jest seems fairly popular and is also what JupyterLab & JupyterHub admin uses, so it feels appropriate here. - Runs Jest unit tests for each change in anything under js/, where the packages live. - Use typed URL objects to construct build URLs, rather than just doing string concatenation. I'll try to slowly move all URL manipulation to the URL object - Use the same babel config for binderhub-client as we do for binder, via a simlink
- Loading branch information
Showing
6 changed files
with
94 additions
and
12 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,28 @@ | ||
# Runs jest based unit tests for the binderhub-client JS package | ||
name: eslint | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "js/**" | ||
push: | ||
paths: | ||
- "js/**" | ||
branches-ignore: | ||
- "dependabot/**" | ||
- "pre-commit-ci-update-config" | ||
- "update-*" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- run: | | ||
cd js/packages/binderhub-client | ||
npm install | ||
- run: | | ||
npm run jest |
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 @@ | ||
../../../babel.config.json |
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,31 @@ | ||
import { BinderRepository } from "."; | ||
|
||
test('Passed in URL object is not modified', () => { | ||
const buildEndpointUrl = new URL("https://test-binder.org/build") | ||
const br = new BinderRepository('gh/test/test', buildEndpointUrl, "token"); | ||
expect(br.buildEndpointUrl.toString()).not.toEqual(buildEndpointUrl.toString()) | ||
}); | ||
|
||
test('Invalid URL errors out', () => { | ||
expect(() => { | ||
new BinderRepository('gh/test/test', '/build', "token"); | ||
}).toThrow(TypeError); | ||
}); | ||
|
||
test('Trailing slash added if needed', () => { | ||
const buildEndpointUrl = new URL("https://test-binder.org/build") | ||
const br = new BinderRepository('gh/test/test', buildEndpointUrl); | ||
expect(br.buildEndpointUrl.toString()).toEqual("https://test-binder.org/build/") | ||
}); | ||
|
||
test('Build URL correctly built from Build Endpoint', () => { | ||
const buildEndpointUrl = new URL("https://test-binder.org/build") | ||
const br = new BinderRepository('gh/test/test', buildEndpointUrl); | ||
expect(br.buildUrl.toString()).toEqual("https://test-binder.org/build/gh/test/test"); | ||
}); | ||
|
||
test('Build URL correctly built from Build Endpoint when used with token', () => { | ||
const buildEndpointUrl = new URL("https://test-binder.org/build") | ||
const br = new BinderRepository('gh/test/test', buildEndpointUrl, 'token'); | ||
expect(br.buildUrl.toString()).toEqual("https://test-binder.org/build/gh/test/test?build_token=token"); | ||
}); |
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