Skip to content

Commit

Permalink
test: resolve gtsRootDir in tests
Browse files Browse the repository at this point in the history
This ensures that the tests are independent of where they are run from.
Remove test that was unnecessary.
  • Loading branch information
ofrobots committed Jun 1, 2018
1 parent 86ffb3b commit 05a1686
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion test/test-clean.ts
Expand Up @@ -25,7 +25,7 @@ import {nop} from '../src/util';
import {withFixtures} from './fixtures';

const OPTIONS: Options = {
gtsRootDir: './',
gtsRootDir: path.resolve(__dirname, '../..'),
targetRootDir: './',
dryRun: false,
yes: false,
Expand Down
3 changes: 2 additions & 1 deletion test/test-format.ts
Expand Up @@ -15,6 +15,7 @@
*/

import test from 'ava';
import * as path from 'path';

import {Options} from '../src/cli';
import * as format from '../src/format';
Expand All @@ -26,7 +27,7 @@ import {withFixtures} from './fixtures';
const BAD_CODE = 'export const foo = 2; ';

const OPTIONS: Options = {
gtsRootDir: './',
gtsRootDir: path.resolve(__dirname, '../..'),
targetRootDir: './',
dryRun: false,
yes: false,
Expand Down
20 changes: 3 additions & 17 deletions test/test-lint.ts
Expand Up @@ -15,6 +15,7 @@
*/

import test from 'ava';
import * as path from 'path';

import {Options} from '../src/cli';
import * as lint from '../src/lint';
Expand All @@ -23,7 +24,7 @@ import {nop} from '../src/util';
import {withFixtures} from './fixtures';

const OPTIONS: Options = {
gtsRootDir: './',
gtsRootDir: path.resolve(__dirname, '../..'),
targetRootDir: './',
dryRun: false,
yes: false,
Expand All @@ -43,27 +44,12 @@ test.serial('createProgram should return an object', async t => {
});
});

// TODO: make the error friendlier. This error implies that our module messed
// up, or is not installed/integrated properly.
test.serial('lint should throw error if tslint is missing', async t => {
await withFixtures(
{
'tsconfig.json': JSON.stringify({files: ['a.ts']}),
'a.ts': GOOD_CODE,
},
async () => {
const err = t.throws(() => {
lint.lint(OPTIONS);
});
t.truthy(err.message.match('Could not find config.*tslint\.json'));
});
});

test.serial('lint should return true on good code', async t => {
await withFixtures(
{
'tsconfig.json': JSON.stringify({files: ['a.ts']}),
'tslint.json': JSON.stringify(TSLINT_CONFIG),
// 'tslint.json': JSON.stringify(TSLINT_CONFIG),
'a.ts': GOOD_CODE,
},
async () => {
Expand Down

0 comments on commit 05a1686

Please sign in to comment.