Skip to content
This repository has been archived by the owner on Feb 15, 2019. It is now read-only.

Commit

Permalink
adding acceptance test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed Dec 31, 2015
1 parent b5ca937 commit 07996dc
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
node_modules
coverage
tmp
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -4,7 +4,6 @@ node_js:
- "4"
- "0.12"
- "0.11"
- "0.10"
- "iojs"

cache:
Expand Down
5 changes: 4 additions & 1 deletion appveyor.yml
@@ -1,7 +1,6 @@
environment:
matrix:
# node.js
- nodejs_version: "0.10"
- nodejs_version: "0.11"
- nodejs_version: "0.12"
- nodejs_version: "4"
Expand All @@ -13,6 +12,10 @@ platform:
- x86
- x64

# Fix line endings in Windows. (runs before repo cloning)
init:
- git config --global core.autocrlf true

# Install scripts. (runs after repo cloning)
install:
- ps: Install-Product node $env:nodejs_version $env:platform
Expand Down
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -4,8 +4,8 @@
"description": "JSON to CSV and vice-versa for ember-i18n",
"main": "to-csv.js",
"scripts": {
"test": "mocha test/acceptance/*.js",
"cover": "istanbul cover node_modules/mocha/bin/_mocha -- test/acceptance/*.js"
"test": "mocha test/**/*-test.js",
"cover": "istanbul cover node_modules/mocha/bin/_mocha -- test/**/*-test.js"
},
"repository": {
"type": "git",
Expand All @@ -17,9 +17,11 @@
"6to5": "^3.5.3",
"csv-parse": "0.0.6",
"csv-stringify": "0.0.6",
"eol": "0.2.0",
"yargs": "^3.0.0"
},
"devDependencies": {
"chai": "^3.0.0",
"coveralls": "^2.0.0",
"istanbul": "0.4.1",
"mocha": "^2.0.0"
Expand Down
50 changes: 50 additions & 0 deletions test/acceptance/to-csv-test.js
@@ -0,0 +1,50 @@
var expect = require('chai').expect;
var test = require('../../lib/test');
var spawn = require('child_process').spawn;
var path = require('path');
var fs = require('fs');

describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
test();
expect([1,2,3].indexOf(5)).to.equal(-1);
expect([1,2,3].indexOf(0)).to.equal(-1);
});
});
});

describe('to-csv', function() {
it('should return -1 when the value is not present', function(done) {
// process.chdir(__dirname);

fs.mkdir('tmp', function(err) {
expect(err).to.be.falsy;

var ps = spawn(process.execPath, [
// path.resolve(__dirname, '../bin/cmd.js'),
'to-csv',
'test/fixtures/locales',
'tmp/i18n.csv',
]);

var out = '';
var err = '';
ps.stdout.on('data', function(buffer) { out += buffer; });
ps.stderr.on('data', function(buffer) { err += buffer; });

ps.on('exit', function(code) {
fs.readFile('tmp/i18n.csv', 'utf-8', function(err, actual) {
expect(err).to.be.falsy;
fs.readFile('test/fixtures/i18n.csv', 'utf-8', function(err, expected) {
expect(err).to.be.falsy;
expect(actual).to.equal(expected);
done();
});
});
expect(err).to.be.falsy;
expect(code).to.equal(0);
});
});
});
});
12 changes: 0 additions & 12 deletions test/acceptance/to-csv.js

This file was deleted.

4 changes: 3 additions & 1 deletion to-csv.js
@@ -1,6 +1,7 @@
var fs = require('fs');
var path = require('path');
var stringify = require('csv-stringify');
var eol = require('eol');
var argv = require('yargs').argv;
require('6to5/register');

Expand Down Expand Up @@ -62,5 +63,6 @@ for (var i in keys) {
}

stringify(lines, function(err, csv) {
fs.writeFileSync(csvPath, csv);
var normalized = eol.auto(csv);
fs.writeFileSync(csvPath, normalized);
});

0 comments on commit 07996dc

Please sign in to comment.