Skip to content

Commit

Permalink
add test fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestalmage committed Dec 27, 2015
1 parent 9d915d4 commit 34924f8
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ var debug = require('debug')('xo');

// Prefer the local installation of XO.
var resolveCwd = require('resolve-cwd');
var hasFlag = require('has-flag');
var localCLI = resolveCwd('xo/cli');

if (localCLI && localCLI !== __filename) {
if (!hasFlag('no-local') && localCLI && localCLI !== __filename) {
debug('Using local install of XO.');
require(localCLI);
return;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"eslint-plugin-no-use-extend-native": "^0.3.2",
"get-stdin": "^5.0.0",
"globby": "^4.0.0",
"has-flag": "^1.0.0",
"home-or-tmp": "^2.0.0",
"meow": "^3.4.2",
"multimatch": "^2.1.0",
Expand Down
6 changes: 6 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'fs';
import test from 'ava';
import tempWrite from 'temp-write';
import execa from 'execa';
import path from 'path';

global.Promise = Promise;

Expand All @@ -10,3 +11,8 @@ test('fix option', async t => {
await execa('../cli.js', ['--fix', filepath]);
t.is(fs.readFileSync(filepath, 'utf8').trim(), 'var foo = 0; foo++;');
});

test('fixture', async t => {
const cwd = path.join(__dirname, 'fixture');
await execa('../../cli.js', ['--no-local'], {cwd});
});
5 changes: 5 additions & 0 deletions test/fixture/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict'

module.exports = function (foo) {
return foo + 'bar'
}
17 changes: 17 additions & 0 deletions test/fixture/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"xo": {
"space": 2,
"semicolon": false,
"overrides": [
{
"files": "test/*.js",
"esnext": true,
"space": 3
},
{
"files": "test/foo.js",
"space": 4
}
]
}
}
6 changes: 6 additions & 0 deletions test/fixture/test/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import test from 'ava'
import fn from '../'

test(t => {
t.is(fn('foo'), fn('foobar'))
})
6 changes: 6 additions & 0 deletions test/fixture/test/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import test from 'ava'
import fn from '../'

test(t => {
t.is(fn('foo'), fn('foobar'))
})

0 comments on commit 34924f8

Please sign in to comment.