forked from coderaiser/cloudcmd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(cloudcmd) show size as <link> for links
- Loading branch information
1 parent
e18ddb2
commit 846f4aa
Showing
5 changed files
with
137 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
const test = require('tape'); | ||
const diff = require('sinon-called-with-diff'); | ||
const sinon = diff(require('sinon')); | ||
const tryCatch = require('try-catch'); | ||
|
||
const { | ||
isContainClass, | ||
} = require('./dom-tree'); | ||
|
||
test('dom: isContainClass: no element', (t) => { | ||
const [e] = tryCatch(isContainClass); | ||
t.equal(e.message, 'element could not be empty!', 'should throw when no element'); | ||
t.end(); | ||
}); | ||
|
||
test('dom: isContainClass: no className', (t) => { | ||
const [e] = tryCatch(isContainClass, {}); | ||
t.equal(e.message, 'className could not be empty!', 'should throw when no element'); | ||
t.end(); | ||
}); | ||
|
||
test('dom: isContainClass: contains', (t) => { | ||
const contains = sinon.stub(); | ||
const el = { | ||
classList: { | ||
contains, | ||
} | ||
}; | ||
|
||
const className = 'hello'; | ||
isContainClass(el, className); | ||
|
||
t.ok(contains.calledWith(className), 'should call contains'); | ||
t.end(); | ||
}); | ||
|
||
test('dom: isContainClass: contains: array', (t) => { | ||
const contains = sinon.stub(); | ||
const el = { | ||
classList: { | ||
contains, | ||
} | ||
}; | ||
|
||
const className = 'hello'; | ||
isContainClass(el, [ | ||
'world', | ||
className, | ||
'hello', | ||
]); | ||
|
||
t.ok(contains.calledWith(className), 'should call contains'); | ||
t.end(); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use strict'; | ||
|
||
const test = require('tape'); | ||
const cloudfunc = require('./cloudfunc'); | ||
const { | ||
_getSize, | ||
} = cloudfunc; | ||
|
||
test('cloudfunc: getSize: dir', (t) => { | ||
const type = 'directory'; | ||
const size = 0; | ||
const result = _getSize({ | ||
type, | ||
size, | ||
}); | ||
|
||
const expected = '<dir>'; | ||
|
||
t.equal(result, expected, 'should equal'); | ||
t.end(); | ||
}); | ||
|
||
test('cloudfunc: getSize: link: dir', (t) => { | ||
const type = 'directory-link'; | ||
const size = 0; | ||
const result = _getSize({ | ||
type, | ||
size, | ||
}); | ||
|
||
const expected = '<link>'; | ||
|
||
t.equal(result, expected, 'should equal'); | ||
t.end(); | ||
}); | ||
|
||
test('cloudfunc: getSize: link: file', (t) => { | ||
const type = 'file-link'; | ||
const size = 0; | ||
const result = _getSize({ | ||
type, | ||
size, | ||
}); | ||
|
||
const expected = '<link>'; | ||
|
||
t.equal(result, expected, 'should equal'); | ||
t.end(); | ||
}); | ||
|
||
test('cloudfunc: getSize: file', (t) => { | ||
const type = 'file'; | ||
const size = '100.00kb'; | ||
const result = _getSize({ | ||
type, | ||
size, | ||
}); | ||
|
||
const expected = '100.00kb'; | ||
|
||
t.equal(result, expected, 'should equal'); | ||
t.end(); | ||
}); |