--- /dev/null
+require('./helper')
+const expect = require('expect')
+const { BaseHistory } = require('../src/history/base')
+
+const parseURL = BaseHistory.prototype.parseURL
+
+describe('URL parsing', () => {
+ it('works with no query no hash', () => {
+ expect(parseURL('/foo')).toEqual({
+ path: '/foo',
+ hash: '',
+ query: {},
+ })
+ })
+
+ it('extracts the query', () => {
+ expect(parseURL('/foo?a=one&b=two')).toEqual({
+ path: '/foo',
+ hash: '',
+ query: {
+ a: 'one',
+ b: 'two',
+ },
+ })
+ })
+
+ it('extracts the hash', () => {
+ expect(parseURL('/foo#bar')).toEqual({
+ path: '/foo',
+ hash: '#bar',
+ query: {},
+ })
+ })
+
+ it('extracts query and hash', () => {
+ expect(parseURL('/foo?a=one#bar')).toEqual({
+ path: '/foo',
+ hash: '#bar',
+ query: { a: 'one' },
+ })
+ })
+})
module.exports = {
preset: 'ts-jest',
testMatch: [
- '**/__tests__/**/*.spec.[jt]s?(x)',
- '**/?(*.)+(spec|test).[jt]s?(x)',
+ '**/__tests__/**/*.spec.[j]s?(x)',
+ // '**/__tests__/**/*.spec.[jt]s?(x)',
+ // '**/?(*.)+(spec|test).[jt]s?(x)',
],
testEnvironment: 'node',
}
"scripts": {
"test:unit": "jest --coverage",
"test:mocha": "mocha -r ts-node/register __tests__/**/*.spec.ts",
+ "test:mocha:js": "mocha -r ts-node/register __tests__/**/*.spec.js",
"test:mocha:dev": "yarn run test:mocha -w --extension ts",
"test:mocha:cov": "nyc -r lcov -e .ts -x \"*.spec.ts\" mocha -r ts-node/register __tests__/**/*.spec.ts && nyc report",
"dev": "webpack-dev-server --mode=development"