assert-element
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "assert-element", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "component/assert": "*" |
0.0.2 / 2015-08-19 | ||
================== | ||
* hasClass: throwing better error for non-string class attributes | ||
* hasChildren: using foreach for children test instead of every | ||
0.0.1 / 2015-08-19 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -56,4 +56,4 @@ | ||
* that number. | ||
* - when a `Function`, it will ensure that the child nodes all match the | ||
* test in that function. (ie: `Array#every()` must return true) | ||
* - when a `Function`, it will run the fn against each node, where they are | ||
* expected to throw if they are invalid. | ||
* | ||
@@ -70,3 +70,3 @@ * @param {Object} node The virtual node to check. | ||
} else if (typeof children === 'function') { | ||
assert(node.children.every(children), 'expected the child nodes to pass the function test'); | ||
node.children.forEach(children); | ||
} else { | ||
@@ -126,4 +126,5 @@ assert(node.children.length > 0, 'expected to find child nodes'); | ||
if (!input) return []; | ||
assert.strictEqual(typeof input, 'string', 'expected a string for the class name'); | ||
if (!input.trim()) return []; | ||
return input.trim().split(/\s+/g); | ||
} |
{ | ||
"name": "assert-element", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Assertions for checking virtual nodes used by Deku/React/etc", | ||
@@ -5,0 +5,0 @@ "repository": "dekujs/assert-element", |
@@ -122,2 +122,6 @@ | ||
})); | ||
it('should throw when the class is not a string', fail(function () { | ||
assertions.hasClass(element('div', { class: { a: true, b: false } }), 'a'); | ||
})); | ||
}); | ||
@@ -186,15 +190,13 @@ | ||
it('should not throw when the fn test passes for every node', function () { | ||
it('should not throw when the fn does not throw for any node', function () { | ||
assertions.hasChildren(element('div', null, 'a'), test); | ||
function test(child) { | ||
return child === 'a'; | ||
} | ||
function test(child) {} | ||
}); | ||
it('should throw when the fn test fails for a single node', fail(function () { | ||
it('should throw when the fn throws for any node', fail(function () { | ||
assertions.hasChildren(element('div', null, 'a', 'b'), test); | ||
function test(child) { | ||
return child === 'a'; | ||
throw new Error('fail'); | ||
} | ||
@@ -201,0 +203,0 @@ })); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17466
302