![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/local/lib/node_modules/forever/node_modules/director/test/server/core/ |
Upload File : |
/* * path-test.js: Tests for the core `.path()` method. * * (C) 2011, Charlie Robbins, Paolo Fragomeni, & the Contributors. * MIT LICENSE * */ var assert = require('assert'), vows = require('vows'), director = require('../../../lib/director'); vows.describe('director/core/path').addBatch({ "An instance of director.Router": { topic: function () { var that = this; that.matched = {}; that.matched['foo'] = []; that.matched['newyork'] = []; var router = new director.Router({ '/foo': function () { that.matched['foo'].push('foo'); } }); return router; }, "the path() method": { "should create the correct nested routing table": function (router) { var that = this; router.path('/regions', function () { this.on('/:state', function(country) { that.matched['newyork'].push('new york'); }); }); assert.isFunction(router.routes.foo.on); assert.isObject(router.routes.regions); assert.isFunction(router.routes.regions['([._a-zA-Z0-9-%()]+)'].on); }, "should dispatch the function correctly": function (router) { router.dispatch('on', '/regions/newyork') router.dispatch('on', '/foo'); assert.equal(this.matched['foo'].length, 1); assert.equal(this.matched['newyork'].length, 1); assert.equal(this.matched['foo'][0], 'foo'); assert.equal(this.matched['newyork'][0], 'new york'); } } } }).export(module);