From: Eduardo San Martin Morote Date: Fri, 12 Apr 2019 20:55:38 +0000 (+0200) Subject: use test files in js because it is much faster X-Git-Tag: v4.0.0-alpha.0~456 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23dc35d1f195b44bf82b5926880854c649ac747b;p=thirdparty%2Fvuejs%2Frouter.git use test files in js because it is much faster --- diff --git a/__tests__/url.spec.js b/__tests__/url.spec.js new file mode 100644 index 00000000..009ee879 --- /dev/null +++ b/__tests__/url.spec.js @@ -0,0 +1,42 @@ +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' }, + }) + }) +}) diff --git a/jest.config.js b/jest.config.js index 09fdee67..adcdbe78 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,8 +1,9 @@ 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', } diff --git a/package.json b/package.json index db9f69e3..382dcb8b 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "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"