hostr
Version:
A simple web server for the current working directory. Used for hello world style web sites hosting only files in current directory structure. Watches files and integrates with LiveReload.
58 lines (43 loc) • 1.16 kB
JavaScript
;
import { strict as assert } from 'node:assert';
import Router from '../lib/router.js';
describe('Router', () => {
describe('#match', () => {
it('Should match routes exactly with same String routes', (done) => {
assert.ok(Router('/').match({
url: '/'
}));
assert.ok(Router('/foo/bar').match({
url: '/foo/bar'
}));
assert.ok(Router('/foo').match({
url: '/foo/quox'
}));
assert.ok(Router('/ipsum').match({
url: '/ipsum'
}));
done();
});
it('Should not match routes without same String routes', (done) => {
assert.ok(!Router('/foo/bar/1').match({
url: '/foo/bar/2'
}));
assert.ok(!Router('/sed/ut').match({
url: '/sed'
}));
assert.ok(!Router('/ipsum').match({
url: '/lorem/ipsum'
}));
done();
});
it('Should match with variables', (done) => {
assert.ok(Router('/foo/bar').match({
url: '/foo/bar'
}));
assert.ok(Router('/foo/quox').match({
url: '/foo/quox'
}));
done();
});
});
});