forked from mootools/mootools-more
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
62 additions
and
8 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 |
---|---|---|
@@ -1,16 +1,69 @@ | ||
describe('HtmlTable.Select', function(){ | ||
|
||
it('should clear selections when emptying a table', function(){ | ||
var SelectableTable = new HtmlTable({ | ||
var getTable = function(){ | ||
return new HtmlTable({ | ||
selectable: true, | ||
useKeyboard: false, | ||
useKeyboard: true, | ||
rows: [[0],[1],[2]] | ||
}); | ||
}; | ||
|
||
it('should clear selections when emptying a table', function(){ | ||
var table = getTable(); | ||
|
||
var row = table.body.getChildren()[0]; | ||
table.selectRow(row); | ||
table.empty(); | ||
expect(table.isSelected(row)).toEqual(false); | ||
}); | ||
|
||
var row = SelectableTable.body.getChildren()[0]; | ||
SelectableTable.selectRow(row); | ||
SelectableTable.empty(); | ||
expect(SelectableTable.isSelected(row)).toEqual(false); | ||
it('keyboard events should change selection', function(){ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
var table = getTable().inject(document.body); | ||
|
||
var rows = table.body.getChildren(); | ||
|
||
Syn.type('[down]', table.toElement()); | ||
|
||
expect(table.isSelected(rows[0])).toEqual(true); | ||
Syn.type('[down]', table.toElement()); | ||
expect(table.isSelected(rows[0])).toEqual(false); | ||
expect(table.isSelected(rows[1])).toEqual(true); | ||
Syn.type('[shift][up]', table.toElement()); | ||
expect(table.isSelected(rows[0])).toEqual(true); | ||
expect(table.isSelected(rows[1])).toEqual(true); | ||
table.dispose(); | ||
}); | ||
|
||
it('table should enable its keyboard', function(){ | ||
var table1 = getTable().inject(document.body); | ||
var table2 = getTable().inject(document.body); | ||
table1.toElement().id = 'one'; | ||
table2.toElement().id = 'two'; | ||
|
||
var t1rows = table1.body.getChildren(); | ||
var t2rows = table2.body.getChildren(); | ||
|
||
Syn.type('[down]', table2.toElement()); | ||
|
||
expect(table2.isSelected(t2rows[0])).toEqual(true); | ||
|
||
//can't get the click to work for some reason... | ||
//Syn.click({}, table1.toElement()); | ||
//works fine if I activate it manually | ||
table1.keyboard.activate(); | ||
|
||
Syn.type('[down]', table1.toElement()); | ||
expect(table1.isSelected(t1rows[0])).toEqual(true); | ||
|
||
//and this should be deactivated, so no change | ||
Syn.type('[down]', table2.toElement()); | ||
expect(table2.isSelected(t2rows[0])).toEqual(true); | ||
|
||
table1.dispose(); | ||
table2.dispose(); | ||
|
||
|
||
}); | ||
|
||
|
||
}); |
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
the cool thing about the it keyword is that it's suppose to make the sentence readable... like:
it("should do foo")
as it's a test i think it's a good practice to make all the spec start with it should.
so this would become something like:
antoher cool jasmine thing is you can do nested describes...
so if you're describing keyboard events within html table you could do:
not sure if you already knew that, but just thought i would bring it up :)
also it should probably be more explicit if possible... like it should change selection when..