[#51,bugfix][xs]: fix bug in pulling of fields from document in createDataset (corrects error in 5fc486d8083a27db21993fc7d58c2c2dae75c17f).

This commit is contained in:
Rufus Pollock 2012-03-31 11:09:10 +01:00
parent d68529c113
commit e3819d8f4e
2 changed files with 5 additions and 3 deletions

View File

@ -29,8 +29,8 @@ this.recline.Backend = this.recline.Backend || {};
datasetInfo.fields = fields;
} else {
if (data) {
datasetInfo.fields = _.map(data[0], function(cell) {
return {id: cell};
datasetInfo.fields = _.map(data[0], function(value, key) {
return {id: key};
});
}
}

View File

@ -7,7 +7,7 @@ var memoryData = {
, name: '1-my-test-dataset'
, id: 'test-dataset'
},
fields: [{id: 'x'}, {id: 'y'}, {id: 'z'}],
fields: [{id: 'id'}, {id: 'x'}, {id: 'y'}, {id: 'z'}],
documents: [
{id: 0, x: 1, y: 2, z: 3}
, {id: 1, x: 2, y: 4, z: 6}
@ -32,6 +32,8 @@ test('Memory Backend: createDataset', function () {
test('Memory Backend: createDataset 2', function () {
var dataset = recline.Backend.createDataset(memoryData.documents);
equal(dataset.fields.length, 4);
deepEqual(['id', 'x', 'y', 'z'], dataset.fields.pluck('id'));
dataset.query();
equal(memoryData.documents.length, dataset.currentDocuments.length);
});