-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
359 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "gluons/es6" | ||
"extends": "gluons/es6", | ||
"env": { | ||
"mocha": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const chalk = require('chalk'); | ||
const rimraf = require('rimraf'); | ||
const path = require('path'); | ||
|
||
const depsNodeModulesPath = path.resolve(__dirname, '../test/deps/node_modules'); | ||
const devDepsNodeModulesPath = path.resolve(__dirname, '../test/dev-deps/node_modules'); | ||
|
||
console.log(chalk.cyan('Cleaning test...')); | ||
|
||
rimraf(depsNodeModulesPath, err => { | ||
if (err) { | ||
console.log(chalk.red('Clean dependencies fail.')); | ||
} else { | ||
console.log(chalk.green('Clean dependencies succeed.')); | ||
} | ||
}); | ||
|
||
rimraf(devDepsNodeModulesPath, err => { | ||
if (err) { | ||
console.log(chalk.red('Clean devDependencies fail.')); | ||
} else { | ||
console.log(chalk.green('Clean devDependencies succeed.')); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const chalk = require('chalk'); | ||
const spawn = require('cross-spawn'); | ||
const path = require('path'); | ||
|
||
const depsPath = path.resolve(__dirname, '../test/deps'); | ||
const devDepsPath = path.resolve(__dirname, '../test/dev-deps'); | ||
|
||
console.log(chalk.cyan('Preparing test...')); | ||
|
||
let depsChild = spawn('npm', ['install'], { | ||
cwd: depsPath, | ||
stdio: 'ignore' | ||
}); | ||
|
||
let devDepsChild = spawn('npm', ['install'], { | ||
cwd: devDepsPath, | ||
stdio: 'ignore' | ||
}); | ||
|
||
depsChild.on('close', code => { | ||
if (code === 0) { | ||
console.log(chalk.green('Prepare dependencies succeed.')); | ||
} else { | ||
console.log(chalk.red('Prepare dependencies fail.')); | ||
} | ||
}); | ||
|
||
devDepsChild.on('close', code => { | ||
if (code === 0) { | ||
console.log(chalk.green('Prepare devDependencies succeed.')); | ||
} else { | ||
console.log(chalk.red('Prepare devDependencies fail.')); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const expect = require('chai').expect; | ||
const spawn = require('cross-spawn'); | ||
const path = require('path'); | ||
|
||
const deps = require('./deps'); | ||
|
||
let cwd = path.resolve(__dirname, './deps'); | ||
let reinstallPath = path.resolve(__dirname, '../reinstall'); | ||
|
||
describe('Dependencies', function () { | ||
this.slow(5000); | ||
this.timeout(10000); | ||
|
||
it('should have dependencies before reinstallation', () => { | ||
let result = deps(); | ||
expect(result).to.exist; | ||
}); | ||
it('should have dependencies after reinstallation', () => new Promise((resolve, reject) => { | ||
let child = spawn('node', [reinstallPath, '--save', 'vue', 'vue-router'], { | ||
cwd | ||
}); | ||
let isErrorThrown = false; | ||
|
||
child.on('error', err => { | ||
if (!isErrorThrown) { | ||
isErrorThrown = true; | ||
reject(err); | ||
} | ||
}); | ||
child.on('close', code => { | ||
if (code === 0) { | ||
resolve(); | ||
} else { | ||
if (!isErrorThrown) { | ||
isErrorThrown = true; | ||
reject(code); | ||
} | ||
} | ||
}); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = function () { | ||
let Vue = require('vue'); | ||
let VueRouter = require('vue-router'); | ||
|
||
Vue.use(VueRouter); | ||
|
||
return new Vue(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "deps", | ||
"version": "1.0.0", | ||
"description": "Deps", | ||
"main": "./index.js", | ||
"private": true, | ||
"scripts": { | ||
"test": "exit 0" | ||
}, | ||
"keywords": [], | ||
"author": "Saran Tanpituckpong <sarunta@gmail.com>", | ||
"license": "UNLICENSED", | ||
"dependencies": { | ||
"vue": "^2.3.3", | ||
"vue-router": "^2.5.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const expect = require('chai').expect; | ||
const spawn = require('cross-spawn'); | ||
const path = require('path'); | ||
|
||
const devDeps = require('./dev-deps'); | ||
|
||
let cwd = path.resolve(__dirname, './dev-deps'); | ||
let reinstallPath = path.resolve(__dirname, '../reinstall'); | ||
|
||
describe('Dev Dependencies', function () { | ||
this.slow(5000); | ||
this.timeout(10000); | ||
|
||
it('should have devDependencies before reinstallation', () => { | ||
let result = devDeps(); | ||
expect(result).to.equal(1); | ||
}); | ||
it('should have devDependencies after reinstallation', () => new Promise((resolve, reject) => { | ||
let child = spawn('node', [reinstallPath, '--save-dev', 'evl', 'nvl'], { | ||
cwd | ||
}); | ||
let isErrorThrown = false; | ||
|
||
child.on('error', err => { | ||
if (!isErrorThrown) { | ||
isErrorThrown = true; | ||
reject(err); | ||
} | ||
}); | ||
child.on('close', code => { | ||
if (code === 0) { | ||
resolve(); | ||
} else { | ||
if (!isErrorThrown) { | ||
isErrorThrown = true; | ||
reject(code); | ||
} | ||
} | ||
}); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = function () { | ||
let evl = require('evl'); | ||
let nvl = require('nvl'); | ||
|
||
return evl( | ||
() => { | ||
throw new Error(); | ||
}, | ||
() => nvl(null, 1) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "dev-deps", | ||
"version": "1.0.0", | ||
"description": "Dev Deps", | ||
"main": "./index.js", | ||
"private": true, | ||
"scripts": { | ||
"test": "exit 0" | ||
}, | ||
"keywords": [], | ||
"author": "Saran Tanpituckpong <sarunta@gmail.com>", | ||
"license": "UNLICENSED", | ||
"devDependencies": { | ||
"evl": "^1.0.1", | ||
"nvl": "^1.0.1" | ||
} | ||
} |
Oops, something went wrong.