Skip to content
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.

Commit

Permalink
AUI-1194 Adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Basto authored and Jonathan Mak committed Apr 30, 2014
1 parent da311a8 commit bbaa37f
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/aui-datatable/tests/unit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
<meta charset="utf-8" />
</head>
<body class="yui3-skin-sam">

<div id="logger"></div>

<div id="datatable"></div>

<script>
YUI({
coverage: ['aui-datatable'],
Expand Down
78 changes: 74 additions & 4 deletions src/aui-datatable/tests/unit/js/tests.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,86 @@
YUI.add('module-tests', function(Y) {

var YgetClassName = Y.getClassName;

var CSS_CELLEDITOR_EDIT_INPUT_NAME = YgetClassName('celleditor', 'edit', 'input', 'name');

var CSS_CELLEDITOR_EDIT_INPUT_VALUE = YgetClassName('celleditor', 'edit', 'input', 'value');

var suite = new Y.Test.Suite('aui-datatable');

var data = [
{ fruit: ['apple'] },
{ fruit: ['cherry'] },
{ fruit: ['cherry'] },
{ fruit: ['apple','cherry'] }
];

var datatable = null, dropdownEditor = null;

suite.add(new Y.Test.Case({
name: 'Automated Tests',
'test is empty': function() {
Y.Assert.pass('No Tests Provided For This Module');
name: 'Datatable',
'Initialize DropDownCellEditor': function() {
dropdownEditor = new Y.DropDownCellEditor({
editable: true,
multiple: true,
options: {
apple: 'Apple',
cherry: 'Cherry',
banana: 'Banana',
kiwi: 'Kiwi'
}
});
},

'Initialize Datatable': function() {
datatable = new Y.DataTable({
boudingBox: '#datatable',
columns: [
{
editor: dropdownEditor,
key: 'fruit',
sortable: true
}
],
data: data,
plugins: [
{
fn: Y.Plugin.DataTableHighlight
}
]
});

Y.Assert.isNotNull(datatable);
},

'Render Datatable': function() {
datatable = datatable.render();

Y.Assert.isNotNull(datatable);
},

'AUI-1194 Allow empty values in BaseCellEditor': function() {
datatable.set('activeCoord', [0, 0]);

datatable._onEditCell({});

dropdownEditor.fire('initEdit');
dropdownEditor.fire('edit');

dropdownEditor.editContainer.one('.' + CSS_CELLEDITOR_EDIT_INPUT_NAME).val('');
dropdownEditor.editContainer.one('.' + CSS_CELLEDITOR_EDIT_INPUT_VALUE).val('');

dropdownEditor.saveOptions();

var options = dropdownEditor.get('options');

Y.Assert.isTrue(options.hasOwnProperty(''));
Y.Assert.isNotUndefined(options['']);
}
}));

Y.Test.Runner.add(suite);

}, '', {
requires: ['test']
requires: ['aui-datatable', 'test']
});

0 comments on commit bbaa37f

Please sign in to comment.