rymizuki/node-hariko

View on GitHub
src/hariko-parser/uri-parser.test.ts

Summary

Maintainability
B
6 hrs
Test Coverage
/* eslint-env mocha */
import assert = require('assert')
import { UriParser } from './uri-parser'

describe('UriParser', () => {
  describe('/path/to', () => {
    it('should be uri entity', () => {
      assert.deepEqual(new UriParser('/path/to').parse(), {
        path: '/path/to',
        template: '/path/to',
        queries: []
      })
    })
  })
  describe('/path/{to}', () => {
    it('should be uri entity', () => {
      assert.deepEqual(new UriParser('/path/{to}').parse(), {
        path: '/path/:to',
        template: '/path/{to}',
        queries: []
      })
    })
  })
  describe('/path/to{?key}', () => {
    it('should be uri entity', () => {
      assert.deepEqual(new UriParser('/path/to{?key}').parse(), {
        path: '/path/to',
        template: '/path/to{?key}',
        queries: ['key']
      })
    })
  })
  describe('/path/{to}{?key}', () => {
    it('should be uri entity', () => {
      assert.deepEqual(new UriParser('/path/{to}{?key}').parse(), {
        path: '/path/:to',
        template: '/path/{to}{?key}',
        queries: ['key']
      })
    })
  })
})