]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: use js for tests, much faster
authorEduardo San Martin Morote <posva13@gmail.com>
Sat, 13 Apr 2019 12:27:11 +0000 (14:27 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Sat, 13 Apr 2019 12:27:11 +0000 (14:27 +0200)
__tests__/helper.d.ts [new file with mode: 0644]
__tests__/html5.spec.js [moved from __tests__/html5.spec.ts with 76% similarity]
__tests__/router.spec.js [moved from __tests__/router.spec.ts with 76% similarity]
__tests__/url.spec.js
__tests__/url.spec.ts [deleted file]
package.json

diff --git a/__tests__/helper.d.ts b/__tests__/helper.d.ts
new file mode 100644 (file)
index 0000000..edb7272
--- /dev/null
@@ -0,0 +1 @@
+export default undefined
similarity index 76%
rename from __tests__/html5.spec.ts
rename to __tests__/html5.spec.js
index 167345a0cf36bc1b95e1eaa851b2e3b13bf4682b..c7e7168951588b388f56cbbdec3fc5fdd54e5ba3 100644 (file)
@@ -1,7 +1,8 @@
-import './helper.js'
-import expect from 'expect'
-import { HTML5History } from '../src/history/html5'
-import { JSDOM } from 'jsdom'
+// @ts-check
+require('./helper')
+const expect = require('expect')
+const { HTML5History } = require('../src/history/html5')
+const { JSDOM } = require('jsdom')
 
 describe('History HTMl5', () => {
   beforeAll(() => {
similarity index 76%
rename from __tests__/router.spec.ts
rename to __tests__/router.spec.js
index b47c351910b342f0600ed2a60f4921f41df575f0..fccd74a1537bbe8b60ecf4790ba9f4fe2f127a87 100644 (file)
@@ -1,8 +1,9 @@
-import './helper.js'
-import expect from 'expect'
-import { HTML5History } from '../src/history/html5'
-import { Router } from '../src/router'
-import { JSDOM } from 'jsdom'
+// @ts-check
+require('./helper')
+const expect = require('expect')
+const { HTML5History } = require('../src/history/html5')
+const { Router } = require('../src/router')
+const { JSDOM } = require('jsdom')
 
 describe('Router', () => {
   beforeAll(() => {
index 009ee879ab8119b7a8b42887c39e7927bd9107fc..cbfc60477b99e8ec81e324d7c7a87bbe63a0043b 100644 (file)
@@ -1,3 +1,4 @@
+// @ts-check
 require('./helper')
 const expect = require('expect')
 const { BaseHistory } = require('../src/history/base')
diff --git a/__tests__/url.spec.ts b/__tests__/url.spec.ts
deleted file mode 100644 (file)
index 70f1e2e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-import './helper.js'
-import expect from 'expect'
-import { BaseHistory } from '../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 382dcb8bae18a46133b73b35e2315efdfeef514a..5ef376d312432be7306773b03f6bff58c3705e94 100644 (file)
@@ -6,8 +6,7 @@
   "license": "MIT",
   "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": "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"