-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adhere to semistandard (except for tabs)
- Loading branch information
Showing
5 changed files
with
55 additions
and
61 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
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 |
---|---|---|
@@ -1,62 +1,62 @@ | ||
/* global describe, it */ | ||
|
||
var assert = require("assert"); | ||
var assert = require('assert'); | ||
var classNames = require('../'); | ||
|
||
describe('classNames', function() { | ||
it('keeps object keys with truthy values', function() { | ||
describe('classNames', function () { | ||
it('keeps object keys with truthy values', function () { | ||
assert.equal(classNames({ | ||
a: true, | ||
b: false, | ||
c: 0, | ||
d: null, | ||
e: undefined, | ||
f: 1, | ||
f: 1 | ||
}), 'a f'); | ||
}); | ||
|
||
it('joins arrays of class names and ignore falsy values', function() { | ||
it('joins arrays of class names and ignore falsy values', function () { | ||
assert.equal(classNames('a', 0, null, undefined, true, 1, 'b'), 'a 1 b'); | ||
}); | ||
|
||
it('supports heterogenous arguments', function() { | ||
it('supports heterogenous arguments', function () { | ||
assert.equal(classNames({a: true}, 'b', 0), 'a b'); | ||
}); | ||
|
||
it('should be trimmed', function() { | ||
it('should be trimmed', function () { | ||
assert.equal(classNames('', 'b', {}, ''), 'b'); | ||
}); | ||
|
||
it('returns an empty string for an empty configuration', function() { | ||
it('returns an empty string for an empty configuration', function () { | ||
assert.equal(classNames({}), ''); | ||
}); | ||
|
||
it('supports an array of class names', function() { | ||
it('supports an array of class names', function () { | ||
assert.equal(classNames(['a', 'b']), 'a b'); | ||
}); | ||
|
||
it('joins array arguments with string arguments', function() { | ||
it('joins array arguments with string arguments', function () { | ||
assert.equal(classNames(['a', 'b'], 'c'), 'a b c'); | ||
assert.equal(classNames('c', ['a', 'b']), 'c a b'); | ||
}); | ||
|
||
it('handles multiple array arguments', function() { | ||
it('handles multiple array arguments', function () { | ||
assert.equal(classNames(['a', 'b'], ['c', 'd']), 'a b c d'); | ||
}); | ||
|
||
it('handles arrays that include falsy and true values', function() { | ||
it('handles arrays that include falsy and true values', function () { | ||
assert.equal(classNames(['a', 0, null, undefined, false, true, 'b']), 'a b'); | ||
}); | ||
|
||
it('handles arrays that include arrays', function() { | ||
it('handles arrays that include arrays', function () { | ||
assert.equal(classNames(['a', ['b', 'c']]), 'a b c'); | ||
}); | ||
|
||
it('handles arrays that include objects', function() { | ||
it('handles arrays that include objects', function () { | ||
assert.equal(classNames(['a', {b: true, c: false}]), 'a b'); | ||
}); | ||
|
||
it('handles deep array recursion', function() { | ||
it('handles deep array recursion', function () { | ||
assert.equal(classNames(['a', ['b', ['c', {d: true}]]]), 'a b c d'); | ||
}); | ||
}); |