mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-03-14 13:08:27 +03:00
javascript test coverage
This commit is contained in:
parent
f0e3940868
commit
c8d2ddbaf3
3 changed files with 20 additions and 12 deletions
4
.github/workflows/linux.yml
vendored
4
.github/workflows/linux.yml
vendored
|
@ -108,8 +108,8 @@ jobs:
|
|||
- name: Upload to Codecov
|
||||
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
files: cobertura.xml, ./coverage/clover.xml
|
||||
# with:
|
||||
# files: cobertura.xml, ./coverage/clover.xml
|
||||
|
||||
- name: generate documentation
|
||||
if: matrix.version == 'stable' && (github.repository == 'mCaptcha/guard')
|
||||
|
|
|
@ -27,7 +27,7 @@ const panelResult = 'hello from panel';
|
|||
const panelRoute = '/panel';
|
||||
const panel = () => (result.result = panelResult);
|
||||
|
||||
const settingsRoute = '/settings';
|
||||
const settingsRoute = '/settings/';
|
||||
const settingsResult = 'hello from settings';
|
||||
const settings = () => (result.result = settingsResult);
|
||||
|
||||
|
@ -35,6 +35,14 @@ const router = new Router();
|
|||
router.register(panelRoute, panel);
|
||||
router.register(settingsRoute, settings);
|
||||
|
||||
test('error checking in router works', () => {
|
||||
try {
|
||||
router.register(settingsRoute, settings);
|
||||
} catch (e) {
|
||||
expect(e.message).toBe('URI exists');
|
||||
}
|
||||
});
|
||||
|
||||
test('checks if Router works', () => {
|
||||
window.history.pushState({}, 'Settings', settingsRoute);
|
||||
router.route();
|
||||
|
|
|
@ -28,7 +28,7 @@ const normalizeUri = (uri: string) => {
|
|||
}
|
||||
return uri;
|
||||
} else {
|
||||
throw new TypeError(`${typeof uri} ${uri}`);
|
||||
throw new TypeError(`Only strings are permitted in URI`);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -68,16 +68,16 @@ export class Router {
|
|||
throw new TypeError('a callback fn must be provided');
|
||||
}
|
||||
|
||||
this.routes.forEach(route => {
|
||||
if (route.uri == uri) {
|
||||
throw new Error(
|
||||
`URI exists. provided URI: ${uri}, registered config: ${route}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
uri = normalizeUri(uri);
|
||||
|
||||
if (this.routes.find(route => {
|
||||
if (route.uri == uri) {
|
||||
return true;
|
||||
}
|
||||
})) {
|
||||
throw new Error('URI exists');
|
||||
};
|
||||
|
||||
const route: routeTuple = {
|
||||
uri,
|
||||
fn,
|
||||
|
|
Loading…
Add table
Reference in a new issue