Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Tidying tests, readying for release
Browse files Browse the repository at this point in the history
  • Loading branch information
hassankhan committed May 16, 2016
1 parent dbd1982 commit 7323084
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const isPlugin = (dependency) => {
*/
const isProject = () => {
const pkg = require('./project').getPackageJson(process.env.RN_PROJECT_ROOT);
var result = false;
let result = false;

if (Object.keys(pkg).length === 0) {
return result;
Expand Down
8 changes: 4 additions & 4 deletions tests/path.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('path', () => {
describe('#isFile', () => {

it('should return true for an existing file', () => {
expect(pathUtils.isFile(path.join(__dirname, 'fixtures', 'file.txt'))).to.deep.equals(true);
expect(pathUtils.isFile(path.join(__dirname, 'fixtures', 'file.txt'))).to.be.true;
});

it('should throw an error for a nonexistent file', () => {
Expand All @@ -28,7 +28,7 @@ describe('path', () => {
describe('#isDirectory', () => {

it('should return true for an existing directory', () => {
expect(pathUtils.isDirectory(path.join(__dirname, 'fixtures'))).to.deep.equals(true);
expect(pathUtils.isDirectory(path.join(__dirname, 'fixtures'))).to.be.true;
});

it('should throw an error for a nonexistent directory', () => {
Expand All @@ -50,7 +50,7 @@ describe('path', () => {
});

pathUtilsMock.makeDirectory(process.cwd());
expect(stub.calledTwice).to.deep.equals(true);
expect(stub.calledTwice).to.be.true;
});

it('should not create a directory if one exists', () => {
Expand All @@ -62,7 +62,7 @@ describe('path', () => {
});

pathUtilsMock.makeDirectory(process.cwd());
expect(stub.calledOnce).to.deep.equals(true);
expect(stub.calledOnce).to.be.true;
});

});
Expand Down
26 changes: 13 additions & 13 deletions tests/process.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

const chai = require('chai');
const sinon = require('sinon');
const rewire = require('rewire');
const path = require('path');
let chai = require('chai');
let sinon = require('sinon');
let rewire = require('rewire');
let path = require('path');

const expect = chai.expect;
let expect = chai.expect;
let spawnError = false;
let processUtilsMock = rewire('../src/process');
processUtilsMock.__set__('spawn', () => {
Expand All @@ -17,32 +17,32 @@ processUtilsMock.__set__('spawn', () => {
describe('process', () => {

describe('#run', () => {
const command = processUtilsMock.run('echo');
let command = processUtilsMock.run('echo');

it('should generate a function around shell command', () => {
expect(typeof command).to.deep.equals('function');
expect(command).to.be.a('function');
});

it('should throw an error if no callback was provided', () => {
expect(() => command()).to.throw('You missed a callback function');
});

it('should invoke a callback after command execution', () => {
const spy = sinon.spy();
let spy = sinon.spy();
command(spy);
expect(spy.callCount).to.equals(1);
expect(spy.calledOnce).to.be.true;
});

it('should throw an error if process exited with a code');
// it('should throw an error if process exited with a code');
// it('should throw an error if process exited with a code', () => {
// const errorCommand = processUtils.run('sleep 10');
// const spy = sinon.spy();
// let errorCommand = processUtilsMock.run('sleep 10');
// let spy = sinon.spy();
// expect(() => errorCommand(spy)).to.throw('Error occurred while executing');
// });

it('should throw an error if spawn ended up with error', () => {
spawnError = true;
const spy = sinon.spy();
let spy = sinon.spy();
expect(() => command(spy)).to.throw();
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/project.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ describe('project', () => {

it('should return the package file as a JSON object', () => {
let projectPath = path.join(__dirname, 'fixtures', 'react-native-project');
expect(projectUtils.getPackageJson(projectPath).name).to.deep.equals('VideoApp');
expect(projectUtils.getPackageJson(projectPath).name).to.eql('VideoApp');
});

it('should return an empty array if no package file exists', () => {
let nonprojectPath = path.join(__dirname, 'fixtures');
expect(projectUtils.getPackageJson(nonprojectPath)).to.deep.equals({});
expect(projectUtils.getPackageJson(nonprojectPath)).to.be.empty;
});

});
Expand Down

0 comments on commit 7323084

Please sign in to comment.