Skip to content

Commit

Permalink
test: update route.handlers shape
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Sep 18, 2018
1 parent 42574ac commit aac1859
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/polka.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,23 @@ test('polka::internals', async t => {
});

test('polka::usage::basic', t => {
t.plan(9);
t.plan(15);

let app = polka();
let arr = [['GET','/'], ['POST','/users'], ['PUT','/users/:id']];

arr.forEach(([m,p]) => {
app.add(m, p, _ => t.pass(`~> matched ${m}(${p}) route`));
t.is(app.routes[m].length, 1, 'added a new `app.route` definition');
t.isFunction(app.handlers[m][p], 'added a new `app.handler` function');
t.isArray(app.handlers[m][p], 'added the router handler as array');
t.is(app.handlers[m][p].length, 1, '~> contains 1 item');
t.isFunction(app.handlers[m][p][0], 1, '~> item is a function');
});

arr.forEach(([m, p]) => {
app.find(m, p).handler();
app.find(m, p).handlers.forEach(fn => {
fn()
});
});
});

Expand Down

0 comments on commit aac1859

Please sign in to comment.