refactor: move tests to unit folder

This commit is contained in:
Clark Du 2018-03-19 18:06:45 +08:00
parent 0e0729ddff
commit db637c4d32
No known key found for this signature in database
GPG Key ID: D0E5986AF78B86D9
23 changed files with 48 additions and 48 deletions

View File

@ -43,8 +43,8 @@
"scripts": {
"test": "npm run build-fixtures && npm run test:unit",
"build-fixtures": "node ./scripts/build-fixtures",
"test:unit": "jest --maxWorkers=4 test/*.test.js",
"test:e2e": "jest --maxWorkers=1 test/e2e/*.test.js",
"test:unit": "jest --maxWorkers=4 test/unit",
"test:e2e": "jest --maxWorkers=1 test/e2e",
"coverage": "codecov",
"lint": "eslint --ext .js,.mjs,.vue bin/* build/ lib/ test/ examples/",
"precommit": "npm run lint",

View File

@ -1,6 +1,6 @@
import { resolve } from 'path'
import { Nuxt, Options } from '..'
import { version } from '../package.json'
import { Nuxt, Options } from '../../'
import { version } from '../../package.json'
describe('basic config defaults', () => {
test('Nuxt.version is same as package', () => {
@ -9,7 +9,7 @@ describe('basic config defaults', () => {
test('modulesDir uses /node_modules as default if not set', async () => {
const options = Options.from({})
const currentNodeModulesDir = resolve(__dirname, '..', 'node_modules')
const currentNodeModulesDir = resolve(__dirname, '..', '..', 'node_modules')
expect(options.modulesDir.includes(currentNodeModulesDir)).toBe(true)
})
})

View File

@ -1,5 +1,5 @@
import { Nuxt, Builder } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt, Builder } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route

View File

@ -1,5 +1,5 @@
import { Nuxt, Generator } from '..'
import { loadFixture } from './utils'
import { Nuxt, Generator } from '../../'
import { loadFixture } from '../utils'
describe('basic fail generate', () => {
test('Fail with routes() which throw an error', async () => {

View File

@ -5,12 +5,12 @@ import { remove } from 'fs-extra'
import serveStatic from 'serve-static'
import finalhandler from 'finalhandler'
import rp from 'request-promise-native'
import { Nuxt, Generator } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt, Generator } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route
const rootDir = resolve(__dirname, 'fixtures/basic')
const rootDir = resolve(__dirname, '..', 'fixtures/basic')
const distDir = resolve(rootDir, '.nuxt-generate')
let nuxt = null

View File

@ -1,6 +1,6 @@
import rp from 'request-promise-native'
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route

View File

@ -1,6 +1,6 @@
import rp from 'request-promise-native'
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route

View File

@ -1,5 +1,5 @@
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let port
// const url = (route) => 'http://localhost:' + port + route

View File

@ -2,15 +2,15 @@ import { exec, spawn } from 'child_process'
import { resolve } from 'path'
import { promisify } from 'util'
import rp from 'request-promise-native'
import { Utils } from '..'
import { Utils } from '../../'
const execify = promisify(exec)
const rootDir = resolve(__dirname, 'fixtures/basic')
const rootDir = resolve(__dirname, '..', 'fixtures/basic')
let port
const url = route => 'http://localhost:' + port + route
const nuxtBin = resolve(__dirname, '..', 'bin', 'nuxt')
const nuxtBin = resolve(__dirname, '..', '..', 'bin', 'nuxt')
describe.skip('cli', () => {
test('nuxt build', async () => {

View File

@ -1,6 +1,6 @@
import rp from 'request-promise-native'
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route

View File

@ -1,6 +1,6 @@
import rp from 'request-promise-native'
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route

View File

@ -1,5 +1,5 @@
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let port

View File

@ -7,7 +7,7 @@ const readFile = promisify(fs.readFile)
describe('dynamic routes', () => {
test('Check .nuxt/router.js', () => {
return readFile(
resolve(__dirname, './fixtures/dynamic-routes/.nuxt/router.js'),
resolve(__dirname, '..', 'fixtures/dynamic-routes/.nuxt/router.js'),
'utf-8'
).then(routerFile => {
routerFile = routerFile

View File

@ -1,6 +1,6 @@
// import rp from 'request-promise-native'
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route

View File

@ -1,7 +1,7 @@
import express from 'express'
import rp from 'request-promise-native'
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route

View File

@ -4,12 +4,12 @@ import { resolve } from 'path'
import serveStatic from 'serve-static'
import finalhandler from 'finalhandler'
import rp from 'request-promise-native'
import { Nuxt, Generator, Options } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt, Generator, Options } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route
const distDir = resolve(__dirname, 'fixtures/basic/.nuxt-generate-fallback')
const distDir = resolve(__dirname, '..', 'fixtures/basic/.nuxt-generate-fallback')
let nuxt = null
let server = null

View File

@ -1,4 +1,4 @@
import { Nuxt, Generator } from '..'
import { Nuxt, Generator } from '../../'
describe('generator', () => {
test('initRoutes with routes (fn => array)', async () => {

View File

@ -1,7 +1,7 @@
import { normalize } from 'path'
import rp from 'request-promise-native'
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route

View File

@ -1,6 +1,6 @@
import { resolve } from 'path'
import { Nuxt, Builder } from '..'
import { loadFixture } from './utils'
import { Nuxt, Builder } from '../../'
import { loadFixture } from '../utils'
describe('nuxt', () => {
test('Nuxt.js Class', () => {
@ -23,7 +23,7 @@ describe('nuxt', () => {
test('Fail to build when no pages/ directory but is in the parent', () => {
const nuxt = new Nuxt({
dev: false,
rootDir: resolve(__dirname, 'fixtures', 'empty', 'pages')
rootDir: resolve(__dirname, '..', 'fixtures', 'empty', 'pages')
})
return new Builder(nuxt).build().catch(err => {

View File

@ -1,5 +1,5 @@
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let nuxt = null

View File

@ -1,7 +1,7 @@
import { Nuxt, Utils } from '..'
import { Nuxt, Utils } from '../../'
import { uniq } from 'lodash'
import rp from 'request-promise-native'
import { loadFixture, getPort } from './utils'
import { loadFixture, getPort } from '../utils'
let port
let nuxt = null

View File

@ -1,5 +1,5 @@
import ansiHTML from 'ansi-html'
import { Utils } from '..'
import { Utils } from '../../'
describe('utils', () => {
test('encodeHtml', () => {

View File

@ -1,6 +1,6 @@
import rp from 'request-promise-native'
import { Nuxt } from '..'
import { loadFixture, getPort } from './utils'
import { Nuxt } from '../../'
import { loadFixture, getPort } from '../utils'
let port
const url = route => 'http://localhost:' + port + route