-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@erikyuzwa added ability to add child component at specific index. cl…
…oses #2540
- Loading branch information
Showing
5 changed files
with
44 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ test/coverage/* | |
.sass-cache | ||
|
||
dist/* | ||
|
||
This comment has been minimized.
Sorry, something went wrong. |
||
.idea/ |
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
1 comment
on commit fc7a166
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -55,14 +55,43 @@ test('should add a child component', function(){
ok(comp.getChildById(child.id()) === child);
});
+test('should add a child component to an index', function(){
- var comp = new Component(getFakePlayer());
- var child = comp.addChild('component');
- ok(comp.children().length === 1);
- ok(comp.children()[0] === child);
- var child0 = comp.addChild('component', {}, 0);
- ok(comp.children().length === 2);
- ok(comp.children()[0] === child0);
- ok(comp.children()[1] === child);
- var child1 = comp.addChild('component', {}, '2');
- ok(comp.children().length === 3);
- ok(comp.children()[2] === child1);
- var child2 = comp.addChild('component', {}, undefined);
- ok(comp.children().length === 4);
- ok(comp.children()[3] === child2);
- var child3 = comp.addChild('component', {}, -1);
- ok(comp.children().length === 5);
- ok(comp.children()[3] === child3);
- ok(comp.children()[4] === child2);
+});
test('addChild should throw if the child does not exist', function() {
var comp = new Component(getFakePlayer());
throws(function() {
- comp.addChild('non-existent-child');
- comp.addChild('non-existent-child');
}, new Error('Component Non-existent-child does not exist'), 'addChild threw');
});
test('should init child components from options', function(){
var comp = new Component(getFakePlayer(), {
children: {
function fancyAlert(arg) {
if(arg) {
$.facebox({div:'#foo'})
}
}