From: Eduardo San Martin Morote Date: Sat, 13 Apr 2019 12:27:11 +0000 (+0200) Subject: test: use js for tests, much faster X-Git-Tag: v4.0.0-alpha.0~455 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63069df3f8eeceda06fb90ab76a7cf226d65afbd;p=thirdparty%2Fvuejs%2Frouter.git test: use js for tests, much faster --- diff --git a/__tests__/helper.d.ts b/__tests__/helper.d.ts new file mode 100644 index 00000000..edb72725 --- /dev/null +++ b/__tests__/helper.d.ts @@ -0,0 +1 @@ +export default undefined diff --git a/__tests__/html5.spec.ts b/__tests__/html5.spec.js similarity index 76% rename from __tests__/html5.spec.ts rename to __tests__/html5.spec.js index 167345a0..c7e71689 100644 --- a/__tests__/html5.spec.ts +++ b/__tests__/html5.spec.js @@ -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(() => { diff --git a/__tests__/router.spec.ts b/__tests__/router.spec.js similarity index 76% rename from __tests__/router.spec.ts rename to __tests__/router.spec.js index b47c3519..fccd74a1 100644 --- a/__tests__/router.spec.ts +++ b/__tests__/router.spec.js @@ -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(() => { diff --git a/__tests__/url.spec.js b/__tests__/url.spec.js index 009ee879..cbfc6047 100644 --- a/__tests__/url.spec.js +++ b/__tests__/url.spec.js @@ -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 index 70f1e2e1..00000000 --- a/__tests__/url.spec.ts +++ /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' }, - }) - }) -}) diff --git a/package.json b/package.json index 382dcb8b..5ef376d3 100644 --- a/package.json +++ b/package.json @@ -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"