* One nastiness along the way (30m delay!) that is worth noting: flot graph was a problem because it turned out that a) (re-)render triggered by dataset attributes change and fields only got set *after* core dataset attributes and so info was rendering. * model.test.js: basic test for Dataset.toTemplateJSON
32 lines
833 B
JavaScript
32 lines
833 B
JavaScript
(function ($) {
|
|
module("Model");
|
|
|
|
test('Field: basics', function () {
|
|
var field = new recline.Model.Field({
|
|
id: 'x'
|
|
});
|
|
equal(field.attributes.label, 'x', 'Field label should be set from id');
|
|
|
|
var field = new recline.Model.Field({
|
|
id: 'x',
|
|
label: 'My label'
|
|
});
|
|
equal(field.attributes.label, 'My label', 'Field label should be set from id but not if explicitly provided');
|
|
|
|
raises(function() {
|
|
var field = new recline.Model.Field('xxx');
|
|
},
|
|
'should throw an error if not passed in a hash with id'
|
|
);
|
|
});
|
|
|
|
test('Dataset', function () {
|
|
var meta = {id: 'test', title: 'xyz'};
|
|
var dataset = new recline.Model.Dataset(meta);
|
|
dataset.fields = new recline.Model.FieldList([{id: 'xx'}, {id: 'yy'}]);
|
|
var out = dataset.toTemplateJSON();
|
|
equal(out.fields.length, 2);
|
|
});
|
|
|
|
})(this.jQuery);
|