]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
use test files in js because it is much faster
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 12 Apr 2019 20:55:38 +0000 (22:55 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 12 Apr 2019 20:55:38 +0000 (22:55 +0200)
__tests__/url.spec.js [new file with mode: 0644]
jest.config.js
package.json

diff --git a/__tests__/url.spec.js b/__tests__/url.spec.js
new file mode 100644 (file)
index 0000000..009ee87
--- /dev/null
@@ -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' },
+    })
+  })
+})
index 09fdee674b6630dcfdbe3dc3862474d6acff9b98..adcdbe787174066b81cfaa2155bf9c8f74e590dd 100644 (file)
@@ -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',
 }
index db9f69e30a4bdd12e36354b40721c5fa74ade09e..382dcb8bae18a46133b73b35e2315efdfeef514a 100644 (file)
@@ -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"