feature(package) mocha -> tape

This commit is contained in:
coderaiser 2016-02-22 06:01:31 -05:00
parent 2248ec193f
commit 8ef751f06f
7 changed files with 49 additions and 41 deletions

2
.gitignore vendored
View file

@ -4,3 +4,5 @@ npm-debug.log*
modules/fancybox/lib/ modules/fancybox/lib/
modules/jquery/src modules/jquery/src
modules/fancybox/demo modules/fancybox/demo
.nyc_output

View file

@ -5,7 +5,8 @@ node_js:
- 0.12 - 0.12
script: script:
- npm test - npm codestyle
- npm run coverage && npm run report
notifications: notifications:
email: email:

View file

@ -30,17 +30,19 @@
}, },
"scripts": { "scripts": {
"start": "node bin/cloudcmd.js", "start": "node bin/cloudcmd.js",
"test": "npm-run-all --parallel lint:* codestyle spell mocha", "codestyle": "npm-run-all --parallel lint:* jscs spell",
"lint:css": "recess css/*.css", "lint:css": "recess css/*.css",
"lint:js": "jshint $npm_package_config_dirs", "lint:js": "jshint $npm_package_config_dirs",
"codestyle": "jscs --esnext $npm_package_config_dirs", "jscs": "jscs --esnext $npm_package_config_dirs",
"mocha": "mocha test/lib", "test": "tape test/**/*.js",
"spell": "yaspeller .", "spell": "yaspeller .",
"wisdom": "bin/release.js", "wisdom": "bin/release.js",
"docker:pull": "docker pull coderaiser/cloudcmd:v`version`", "docker:pull": "docker pull coderaiser/cloudcmd:v`version`",
"docker:tag": "docker tag coderaiser/cloudcmd:latest coderaiser/cloudcmd:`version`", "docker:tag": "docker tag coderaiser/cloudcmd:latest coderaiser/cloudcmd:`version`",
"docker:push": "docker push coderaiser/cloudcmd:`version`", "docker:push": "docker push coderaiser/cloudcmd:`version`",
"docker": "npm-run-all docker:pull docker:tag docker:push" "docker": "npm-run-all docker:pull docker:tag docker:push",
"coverage": "nyc npm test",
"report": "nyc report --reporter=text-lcov | coveralls"
}, },
"directories": { "directories": {
"man": "man" "man": "man"
@ -84,16 +86,17 @@
"writejson": "~1.1.0" "writejson": "~1.1.0"
}, },
"devDependencies": { "devDependencies": {
"coveralls": "^2.11.6",
"jscs": "^2.7.0", "jscs": "^2.7.0",
"jshint": "^2.8.0", "jshint": "^2.8.0",
"minor": "^1.2.2", "minor": "^1.2.2",
"mocha": "^2.3.4",
"morgan": "^1.6.1", "morgan": "^1.6.1",
"npm-run-all": "^1.4.0", "npm-run-all": "^1.4.0",
"nyc": "^5.6.0",
"place": "^1.1.4", "place": "^1.1.4",
"recess": "^1.1.9", "recess": "^1.1.9",
"shortdate": "^1.0.1", "shortdate": "^1.0.1",
"should": "^8.0.0", "tape": "^4.4.0",
"version-io": "^1.2.5", "version-io": "^1.2.5",
"yaspeller": "^2.6.0" "yaspeller": "^2.6.0"
}, },

View file

@ -2,24 +2,28 @@
<span data-name="js-type" class="mini-icon "></span> <span data-name="js-type" class="mini-icon "></span>
<span data-name="js-name" class="name reduce-text">name</span> <span data-name="js-name" class="name reduce-text">name</span>
<span data-name="js-size" class="size reduce-text">size</span> <span data-name="js-size" class="size reduce-text">size</span>
<span data-name="js-date" class="date reduce-text">date</span>
<span data-name="js-owner" class="owner reduce-text">owner</span> <span data-name="js-owner" class="owner reduce-text">owner</span>
<span data-name="js-mode" class="mode reduce-text">mode</span> <span data-name="js-mode" class="mode reduce-text">mode</span>
</div><ul data-name="js-files" class="files"><li draggable="true" data-name="js-file-.." class=""> </div><ul data-name="js-files" class="files"><li draggable="true" data-name="js-file-.." class="">
<span data-name="js-type" class="mini-icon directory"></span> <span data-name="js-type" class="mini-icon directory"></span>
<span data-name="js-name" class="name reduce-text"><a href="/fs/etc" title=".." draggable="true">..</a></span> <span data-name="js-name" class="name reduce-text"><a href="/fs/etc" title=".." draggable="true">..</a></span>
<span data-name="js-size" class="size reduce-text">&lt;dir&gt;</span> <span data-name="js-size" class="size reduce-text">&lt;dir&gt;</span>
<span data-name="js-date" class="date reduce-text">--.--.----</span>
<span data-name="js-owner" class="owner reduce-text">.</span> <span data-name="js-owner" class="owner reduce-text">.</span>
<span data-name="js-mode" class="mode reduce-text">--- --- ---</span> <span data-name="js-mode" class="mode reduce-text">--- --- ---</span>
</li><li draggable="true" data-name="js-file-applnk" class=""> </li><li draggable="true" data-name="js-file-applnk" class="">
<span data-name="js-type" class="mini-icon directory"></span> <span data-name="js-type" class="mini-icon directory"></span>
<span data-name="js-name" class="name reduce-text"><a href="/fs/etc/X11/applnk" title="applnk" draggable="true">applnk</a></span> <span data-name="js-name" class="name reduce-text"><a href="/fs/etc/X11/applnk" title="applnk" draggable="true">applnk</a></span>
<span data-name="js-size" class="size reduce-text">&lt;dir&gt;</span> <span data-name="js-size" class="size reduce-text">&lt;dir&gt;</span>
<span data-name="js-date" class="date reduce-text">21.02.2016</span>
<span data-name="js-owner" class="owner reduce-text">root</span> <span data-name="js-owner" class="owner reduce-text">root</span>
<span data-name="js-mode" class="mode reduce-text">rwx r-x r-x</span> <span data-name="js-mode" class="mode reduce-text">rwx r-x r-x</span>
</li><li draggable="true" data-name="js-file-prefdm" class=""> </li><li draggable="true" data-name="js-file-prefdm" class="">
<span data-name="js-type" class="mini-icon text-file"></span> <span data-name="js-type" class="mini-icon text-file"></span>
<span data-name="js-name" class="name reduce-text"><a href="/fs/etc/X11/prefdm" title="prefdm" target="_blank" draggable="true">prefdm</a></span> <span data-name="js-name" class="name reduce-text"><a href="/fs/etc/X11/prefdm" title="prefdm" target="_blank" draggable="true">prefdm</a></span>
<span data-name="js-size" class="size reduce-text">1.30kb</span> <span data-name="js-size" class="size reduce-text">1.30kb</span>
<span data-name="js-date" class="date reduce-text">21.02.2016</span>
<span data-name="js-owner" class="owner reduce-text">root</span> <span data-name="js-owner" class="owner reduce-text">root</span>
<span data-name="js-mode" class="mode reduce-text">rwx r-x r-x</span> <span data-name="js-mode" class="mode reduce-text">rwx r-x r-x</span>
</li></ul> </li></ul>

View file

@ -1,8 +1,6 @@
(function() { (function() {
'use strict'; 'use strict';
/* global describe, it */
var DIR = __dirname + '/../../', var DIR = __dirname + '/../../',
LIBDIR = DIR + 'lib/', LIBDIR = DIR + 'lib/',
TMPLDIR = DIR + 'tmpl/', TMPLDIR = DIR + 'tmpl/',
@ -12,6 +10,8 @@
files = require('files-io'), files = require('files-io'),
rendy = require('rendy'), rendy = require('rendy'),
test = require('tape'),
FS_DIR = TMPLDIR + 'fs/', FS_DIR = TMPLDIR + 'fs/',
EXPECT_PATH = DIR + 'test/lib/cloudfunc.html', EXPECT_PATH = DIR + 'test/lib/cloudfunc.html',
@ -27,11 +27,13 @@
files : [{ files : [{
name: 'applnk', name: 'applnk',
size: 'dir', size: 'dir',
date: '21.02.2016',
uid : 0, uid : 0,
mode: 'rwx r-x r-x' mode: 'rwx r-x r-x'
}, { }, {
name: 'prefdm', name: 'prefdm',
size: '1.30kb', size: '1.30kb',
date: '21.02.2016',
uid : 0, uid : 0,
mode: 'rwx r-x r-x' mode: 'rwx r-x r-x'
}] }]
@ -51,15 +53,9 @@
'</a>/X11/' + '</a>/X11/' +
'</span>' + '</span>' +
'</div>'; '</div>';
describe('cloudfunc', function() {
it('should check', function() {
check();
});
});
function check() { test(function(t) {
var paths = {}, var paths = {},
filesList = TMPL_PATH.map(function(name) { filesList = TMPL_PATH.map(function(name) {
var path = FS_DIR + name + '.hbs'; var path = FS_DIR + name + '.hbs';
@ -119,9 +115,14 @@
result: result.substr(i) result: result.substr(i)
})); }));
throw('buildFromJSON: Not OK'); console.log('buildFromJSON: Not OK');
} }
t.equal(Expect, result, 'should be equal rendered json data');
t.end();
} }
}); });
} });
})(); })();

View file

@ -1,30 +1,27 @@
(function() { (function() {
'use strict'; 'use strict';
/*global describe, it */ var test = require('tape'),
var should = require('should'),
DIR = '../../', DIR = '../../',
Util = require(DIR + 'lib/util'); Util = require(DIR + 'lib/util');
describe('Util', function() {
describe('getExt', function() { test('getExt: no extension', function(t) {
it('should return "" when extension is none', function() { var EXT = '',
var EXT = '', name = 'file-withot-extension',
name = 'file-withot-extension', ext = Util.getExt(name);
ext = Util.getExt(name);
t.equal(ext, EXT, 'should return "" when extension is none');
should(ext).eql(EXT); t.end();
}); });
it('should return ".png" in files "picture.png"', function() { test('getExt: return extension', function(t) {
var EXT = '.png', var EXT = '.png',
name = 'picture.png', name = 'picture.png',
ext = Util.getExt(name); ext = Util.getExt(name);
should(ext).eql(EXT); t.equal(ext, EXT, 'should return ".png" in files "picture.png"');
}); t.end();
});
}); });
})(); })();

View file

@ -2,7 +2,7 @@
<span data-name="js-type" class="mini-icon {{ type }}"></span> <span data-name="js-type" class="mini-icon {{ type }}"></span>
<span data-name="js-name" class="name reduce-text">{{ name }}</span> <span data-name="js-name" class="name reduce-text">{{ name }}</span>
<span data-name="js-size" class="size reduce-text">{{ size }}</span> <span data-name="js-size" class="size reduce-text">{{ size }}</span>
<span data-name="js-date" class="date reduce-text">{{ date }} </span> <span data-name="js-date" class="date reduce-text">{{ date }}</span>
<span data-name="js-owner" class="owner reduce-text">{{ owner }}</span> <span data-name="js-owner" class="owner reduce-text">{{ owner }}</span>
<span data-name="js-mode" class="mode reduce-text">{{ mode }}</span> <span data-name="js-mode" class="mode reduce-text">{{ mode }}</span>
</{{ tag }}> </{{ tag }}>