Skip to content

Commit

Permalink
Moved first/last tests to proper section
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Aug 28, 2018
1 parent 0dd41dd commit 6a89795
Showing 1 changed file with 58 additions and 57 deletions.
115 changes: 58 additions & 57 deletions packages/perspective/test/js/pivots.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,64 @@ module.exports = (perspective) => {
expect(answer).toEqual(result);
});

it("['z'], first by index", async function () {
var table = perspective.table(data);
var view = table.view({
row_pivot: ['z'],
aggregate: [{op: 'first by index', column:'x'}],
});
var answer = [
{__ROW_PATH__: [], x: 1},
{__ROW_PATH__: [ false ], x: 2},
{__ROW_PATH__: [ true ], x: 1},
];
let result = await view.to_json();
expect(answer).toEqual(result);
});

it("['z'], last by index", async function () {
var table = perspective.table(data);
var view = table.view({
row_pivot: ['z'],
aggregate: [{op: 'last by index', column:'x'}],
});
var answer = [
{__ROW_PATH__: [], x: 4},
{__ROW_PATH__: [ false ], x: 4},
{__ROW_PATH__: [ true ], x: 3},
];
let result = await view.to_json();
expect(answer).toEqual(result);
});

it("['z'], last", async function () {
var table = perspective.table(data);
var view = table.view({
row_pivot: ['z'],
aggregate: [{op: 'last', column:'x'}],
});
var answer = [
{__ROW_PATH__: [], x: 3},
{__ROW_PATH__: [ false ], x: 4},
{__ROW_PATH__: [ true ], x: 3},
];
let result = await view.to_json();
expect(answer).toEqual(result);

table.update([
{'x': 1, 'y':'c', 'z': true},
{'x': 2, 'y':'d', 'z': false}
]);
var answerAfterUpdate = [
{__ROW_PATH__: [], x: 1},
{__ROW_PATH__: [ false ], x: 2},
{__ROW_PATH__: [ true ], x: 1},
];
let result2 = await view.to_json();
expect(answerAfterUpdate).toEqual(result2);
});


});

describe("Aggregates with nulls", function () {
Expand Down Expand Up @@ -203,63 +261,6 @@ module.exports = (perspective) => {
expect(answer).toEqual(result);
});

it("['z'], first by index", async function () {
var table = perspective.table(data);
var view = table.view({
row_pivot: ['z'],
aggregate: [{op: 'first by index', column:'x'}],
});
var answer = [
{__ROW_PATH__: [], x: 1},
{__ROW_PATH__: [ false ], x: 2},
{__ROW_PATH__: [ true ], x: 1},
];
let result = await view.to_json();
expect(answer).toEqual(result);
});

it("['z'], last by index", async function () {
var table = perspective.table(data);
var view = table.view({
row_pivot: ['z'],
aggregate: [{op: 'last by index', column:'x'}],
});
var answer = [
{__ROW_PATH__: [], x: 4},
{__ROW_PATH__: [ false ], x: 4},
{__ROW_PATH__: [ true ], x: 3},
];
let result = await view.to_json();
expect(answer).toEqual(result);
});

it("['z'], last", async function () {
var table = perspective.table(data);
var view = table.view({
row_pivot: ['z'],
aggregate: [{op: 'last', column:'x'}],
});
var answer = [
{__ROW_PATH__: [], x: 3},
{__ROW_PATH__: [ false ], x: 4},
{__ROW_PATH__: [ true ], x: 3},
];
let result = await view.to_json();
expect(answer).toEqual(result);

table.update([
{'x': 1, 'y':'c', 'z': true},
{'x': 2, 'y':'d', 'z': false}
]);
var answerAfterUpdate = [
{__ROW_PATH__: [], x: 1},
{__ROW_PATH__: [ false ], x: 2},
{__ROW_PATH__: [ true ], x: 1},
];
let result2 = await view.to_json();
expect(answerAfterUpdate).toEqual(result2);
});

});

describe("Row pivot", function() {
Expand Down

0 comments on commit 6a89795

Please sign in to comment.