Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwohl committed Jun 22, 2016
1 parent ca98aee commit 2a7475a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rules:
linebreak-style: [2, unix]
no-console: [0]
no-unused-vars: [1]
no-octal: [0]
# commas go last
comma-style: [1, last]
# variable comes before literal in conditional
Expand Down
2 changes: 1 addition & 1 deletion extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = new Extension({
// how do start this type of artwork? currently two token replacements, $filepath and $url
'start_command': function(args, tokens) {
// make sure the file is executable
fs.chmodSync(tokens.$filepath, 755);
fs.chmodSync(tokens.$filepath, 0755);
// start command just executes the file ($filepath is absolute, includes leading slash)
return '.$filepath';
},
Expand Down
39 changes: 35 additions & 4 deletions test/extension.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var assert = require('assert'),
fs = require('fs'),
Extension = require('openframe-extension'),
OpenFrameworksExtension = require('../extension');

Expand All @@ -24,11 +25,41 @@ describe('properties', function() {
assert(format.start_command);
assert(typeof format.start_command === 'string' || typeof format.start_command === 'function');

if (typeof format.start_command === 'function') {
assert(typeof format.start_command() === 'string');
}

assert(format.end_command);
assert(typeof format.end_command === 'string');
});
});

describe('start_command', function() {
var tokens = {
$filepath: __dirname + '/test.sh'
};

before(function() {
fs.chmodSync(tokens.$filepath, 777);
});

it('should return a string', function() {
var format = OpenFrameworksExtension.props.format,
command = format.start_command(null, tokens),
expected = '.$filepath';

assert(typeof command === 'string');
assert.equal(command, expected);
});

it('should make the file specified by tokens.$filepath executable', function() {
var format = OpenFrameworksExtension.props.format,
expected = 100755,
stats;

// execute start command
format.start_command(null, tokens);
stats = fs.statSync(tokens.$filepath);

console.log(stats.mode);

assert.equal(parseInt(stats.mode.toString(8), 10), expected);
});

});
Empty file added test/test.sh
Empty file.

0 comments on commit 2a7475a

Please sign in to comment.