From 3ea6ea6e10cc2ab029f585fbc652a9c65b511013 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 22 Jun 2014 00:11:17 +0200 Subject: [PATCH] Added tests for data objects and new table api. --- public/assets/tests/table.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/public/assets/tests/table.js b/public/assets/tests/table.js index ffd3f9aa4..ef9e87792 100644 --- a/public/assets/tests/table.js +++ b/public/assets/tests/table.js @@ -519,3 +519,39 @@ test( "table test 3", function() { equal( el.find('tbody > tr:nth-child(2) > td:nth-child(3) > a > span').data('xxx'), '56', 'check row 2') }); + +test( "table test 4", function() { + App.i18n.set('de') + + $('#table').append('

table with data

') + var el = $('#table-data1') + + data = [ + { name: 'some name 1', data: 'some data 1', active: true }, + { name: 'some name 2', data: 'some data 2', active: false }, + { name: 'some name 3', data: 'some data 3', active: true }, + ] + new App.ControllerTable({ + el: el, + overview: ['name', 'data', 'active'], + attributes: [ + { name: 'name', display: 'Name', type: 'text', style: 'width: 10%' }, + { name: 'data', display: 'Data', type: 'text' }, + { name: 'active', display: 'Active', type: 'text' }, + ], + objects: data + }); + + equal( el.find('table > thead > tr').length, 1, 'row count') + equal( el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header') + equal( el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Data', 'check header') + equal( el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header') + equal( el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1') + equal( el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some name 1', 'check row 1') + equal( el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'some data 1', 'check row 1') + equal( el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1') + equal( el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2') + equal( el.find('tbody > tr:nth-child(2) > td:first').text().trim(), 'some name 2', 'check row 2') + equal( el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'some data 2', 'check row 2') + equal( el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'false', 'check row 2') +});