mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-27 01:36:28 +00:00
feature(util) add tests
This commit is contained in:
parent
b01b1be71b
commit
18e1f4ce22
1 changed files with 64 additions and 0 deletions
64
test/lib/util.js
Normal file
64
test/lib/util.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
/*global describe, it */
|
||||
|
||||
var should = require('should'),
|
||||
DIR = '../../',
|
||||
Util = require(DIR + 'lib/util');
|
||||
|
||||
describe('Util', function() {
|
||||
describe('getExt', function() {
|
||||
it('should return "" when extension is none', function() {
|
||||
var EXT = '',
|
||||
name = 'file-withot-extension',
|
||||
ext = Util.getExt(name);
|
||||
|
||||
should(ext).eql(EXT);
|
||||
});
|
||||
|
||||
it('should return ".png" in files "picture.png"', function() {
|
||||
var EXT = '.png',
|
||||
name = 'picture.png',
|
||||
ext = Util.getExt(name);
|
||||
|
||||
should(ext).eql(EXT);
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkExt', function() {
|
||||
it('should return true when extension is same', function() {
|
||||
var EXT = 'png',
|
||||
name = 'picture.png',
|
||||
same = Util.checkExt(name, EXT);
|
||||
|
||||
same.should.be.true;
|
||||
});
|
||||
|
||||
it('should return false when extension is not same', function() {
|
||||
var EXT = 'jpg',
|
||||
name = 'picture.png',
|
||||
same = Util.checkExt(name, EXT);
|
||||
|
||||
same.should.be.false;
|
||||
});
|
||||
|
||||
it('should return true when one item of extensions array is same', function() {
|
||||
var EXT = ['jpg', 'png'],
|
||||
name = 'picture.png',
|
||||
same = Util.checkExt(name, EXT);
|
||||
|
||||
same.should.be.true;
|
||||
});
|
||||
|
||||
it('should return false when no one item of extensions array is same', function() {
|
||||
var EXT = ['jpg', 'gif'],
|
||||
name = 'picture.png',
|
||||
same = Util.checkExt(name, EXT);
|
||||
|
||||
same.should.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue