Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract local path logic and add tests. #341

Merged
merged 15 commits into from
Feb 11, 2017
Prev Previous commit
Next Next commit
Fix weird race issues.
Always pass call callback function on generate.

Previously tests were randomly failing when running few times in a row.
  • Loading branch information
zigomir committed Feb 10, 2017
commit 1f15a0184fde38f275b538edc56b8fae91a6262f
16 changes: 8 additions & 8 deletions test/e2e/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const generate = require('../../lib/generate')
const metadata = require('../../lib/options')
const { isLocalPath, getTemplatePath } = require('../../lib/local-path')

const MOCK_META_JSON_PATH = './test/e2e/mock-meta-json'
const MOCK_TEMPLATE_REPO_PATH = './test/e2e/mock-template-repo'
const MOCK_META_JSON_PATH = path.resolve('./test/e2e/mock-meta-json')
const MOCK_TEMPLATE_REPO_PATH = path.resolve('./test/e2e/mock-template-repo')
const MOCK_TEMPLATE_BUILD_PATH = path.resolve('./test/e2e/mock-template-build')
const MOCK_METADATA_REPO_JS_PATH = './test/e2e/mock-metadata-repo-js'
const MOCK_SKIP_GLOB = './test/e2e/mock-skip-glob'
const MOCK_METADATA_REPO_JS_PATH = path.resolve('./test/e2e/mock-metadata-repo-js')
const MOCK_SKIP_GLOB = path.resolve('./test/e2e/mock-skip-glob')

function monkeyPatchInquirer (answers) {
// monkey patch inquirer
Expand Down Expand Up @@ -68,16 +68,16 @@ describe('vue-cli', () => {
})
})

it('adds additional data to meta data', () => {
const data = generate('test', MOCK_META_JSON_PATH, MOCK_TEMPLATE_BUILD_PATH)
it('adds additional data to meta data', done => {
const data = generate('test', MOCK_META_JSON_PATH, MOCK_TEMPLATE_BUILD_PATH, done)
expect(data.destDirName).to.equal('test')
expect(data.inPlace).to.equal(false)
})

it('sets `inPlace` to true when generating in same directory', () => {
it('sets `inPlace` to true when generating in same directory', done => {
const currentDir = process.cwd()
process.chdir(MOCK_TEMPLATE_BUILD_PATH)
const data = generate('test', MOCK_META_JSON_PATH, MOCK_TEMPLATE_BUILD_PATH)
const data = generate('test', MOCK_META_JSON_PATH, MOCK_TEMPLATE_BUILD_PATH, done)
expect(data.destDirName).to.equal('test')
expect(data.inPlace).to.equal(true)
process.chdir(currentDir)
Expand Down