From a6cb0144fad8f4e0960d9ca90abc6119bc0685bf Mon Sep 17 00:00:00 2001 From: kookookchoozeus Date: Sat, 23 Apr 2016 19:18:20 +0100 Subject: [PATCH] Fixing changed tests to be more consistent with the code base --- test/cli-test.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/test/cli-test.js b/test/cli-test.js index 6593769..1e78eea 100644 --- a/test/cli-test.js +++ b/test/cli-test.js @@ -2,20 +2,19 @@ require('./helper'); var fs = require('fs'); var path = require('path'); +var child_process = require('child_process'); var _files = path.join(__dirname, '_files'); var cliTxt = path.resolve(_files, 'cli.txt'); var cliPartialsTxt = path.resolve(_files, 'cli_with_partials.txt'); var moduleVersion = require('../package').version; -var child_process = require('child_process'); - function changeForOS(command) { if(process.platform === 'win32') { - return command. - replace(/bin\/mustache/g, 'node bin\\mustache'). - replace(/\bcat\b/g, 'type'). - replace(/\//g, '\\'); + return command + .replace(/bin\/mustache/g, 'node bin\\mustache') + .replace(/\bcat\b/g, 'type') + .replace(/\//g, '\\'); } return command; @@ -31,7 +30,6 @@ describe('Mustache CLI', function () { var expectedOutput; it('writes syntax hints into stderr when runned with wrong number of arguments', function(done) { - exec('bin/mustache', function(err, stdout, stderr) { assert.notEqual(stderr.indexOf('Syntax'), -1); done(); @@ -101,17 +99,14 @@ describe('Mustache CLI', function () { it('writes it couldnt find template into stderr when second argument doesnt resolve to a file', function(done) { exec('bin/mustache test/_files/cli.json test/_files/non-existing-template.mustache', function(err, stdout, stderr) { - console.log(stderr); - assert.notEqual(stderr.indexOf('Could not find file:'), -1); - assert.notEqual(stderr.indexOf(changeForOS('test/_files/non-existing-template.mustache')), -1); + assert.isOk(/Could not find file: .+non-existing-template\.mustache/.test(stderr)); done(); }); }); it('writes it couldnt find view into stderr when first argument doesnt resolve to a file', function(done) { exec('bin/mustache test/_files/non-existing-view.json test/_files/cli.mustache', function(err, stdout, stderr) { - assert.notEqual(stderr.indexOf('Could not find file:'), -1); - assert.notEqual(stderr.indexOf(changeForOS('test/_files/non-existing-view.json')), -1); + assert.isOk(/Could not find file: .+non-existing-view\.json/.test(stderr)); done(); }); });