From 2e95b52425d85553bc9e93debb46d186d2f5cf31 Mon Sep 17 00:00:00 2001 From: shaun554 Date: Mon, 27 Aug 2018 01:59:29 +0800 Subject: [PATCH] test($core): use es6 import ref: https://github.com/facebook/jest/issues/6835 --- .babelrc | 9 --------- babel.config.js | 9 +++++++++ .../@vuepress/core/__test__/plugin-api/Option.spec.js | 5 +---- .../@vuepress/core/__test__/plugin-api/PluginAPI.spec.js | 4 ++-- .../core/__test__/plugin-api/PluginUtil.spec.js | 6 ++---- 5 files changed, 14 insertions(+), 19 deletions(-) delete mode 100644 .babelrc create mode 100644 babel.config.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 427e7a4..0000000 --- a/.babelrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "env": { - "test": { - "presets": [ - ["@babel/preset-env", { "targets": { "node": 8 }}] - ] - } - } -} diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..8f54044 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,9 @@ +module.exports = { + 'env': { + 'test': { + 'presets': [ + ['@babel/preset-env', { 'targets': { 'node': 8 }}] + ] + } + } +} diff --git a/packages/@vuepress/core/__test__/plugin-api/Option.spec.js b/packages/@vuepress/core/__test__/plugin-api/Option.spec.js index a80b3db..9670814 100644 --- a/packages/@vuepress/core/__test__/plugin-api/Option.spec.js +++ b/packages/@vuepress/core/__test__/plugin-api/Option.spec.js @@ -1,7 +1,4 @@ -// TODO change to ES6 import -// https://github.com/facebook/jest/issues/6835 - -const Option = require('../../lib/plugin-api/Option') +import Option from '../../lib/plugin-api/Option' describe('Option', () => { test('shoould option record the key', () => { diff --git a/packages/@vuepress/core/__test__/plugin-api/PluginAPI.spec.js b/packages/@vuepress/core/__test__/plugin-api/PluginAPI.spec.js index 32895dd..740ca7f 100644 --- a/packages/@vuepress/core/__test__/plugin-api/PluginAPI.spec.js +++ b/packages/@vuepress/core/__test__/plugin-api/PluginAPI.spec.js @@ -2,8 +2,8 @@ jest.mock('vuepress-plugin-a') jest.mock('vuepress-plugin-b') jest.mock('@org/vuepress-plugin-a') -const PluginAPI = require('../../lib/plugin-api/index') -const { PLUGIN_OPTION_MAP } = require('../../lib/plugin-api/constants') +import PluginAPI from '../../lib/plugin-api/index' +import { PLUGIN_OPTION_MAP } from '../../lib/plugin-api/constants' describe('Plugin', () => { test('should \'registerOption\' work.', () => { diff --git a/packages/@vuepress/core/__test__/plugin-api/PluginUtil.spec.js b/packages/@vuepress/core/__test__/plugin-api/PluginUtil.spec.js index f0fe55b..b1c009f 100644 --- a/packages/@vuepress/core/__test__/plugin-api/PluginUtil.spec.js +++ b/packages/@vuepress/core/__test__/plugin-api/PluginUtil.spec.js @@ -1,18 +1,16 @@ jest.mock('vuepress-plugin-a') jest.mock('@org/vuepress-plugin-a') -const { +import { resolvePlugin, hydratePlugin, resolveScopePackage -} = require('../../lib/plugin-api/util') +} from '../../lib/plugin-api/util' function resolveMockModule (name) { return require(`../../../../../__mocks__/${name}`) } -// const Plugin = require('../../lib/plugin-api/index') - describe('resolvePlugin', () => { test('should resolve scope packages correctly.', () => { const pkg1 = resolveScopePackage('@vuepress/plugin-a')