datahub/test/model.test.js
Rufus Pollock 4074f380d8 [#25,view,refactor][s]: get views working with new field setup (fixes #25).
* 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
2012-02-18 09:07:35 +00:00

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);