Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rjackson/pivot.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Jackson committed Mar 27, 2012
2 parents 9fdee08 + 72aad43 commit 8c92312
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions spec/pivotjs_spec.js
Expand Up @@ -10,6 +10,10 @@ describe('pivot', function () {
pivot.csv(sample_csv)
});

afterEach(function () {
pivot.reset();
});

describe('CSV', function () {
it('can parse csv into an array', function(){
expect(pivot.data().raw[0]).toEqual({last_name:'Jackson',first_name:'Robert',zip_code:'34471'});
Expand All @@ -26,15 +30,22 @@ describe('pivot', function () {
});

describe('Filters', function() {
beforeEach(function () {
pivot.filters().set({last_name: 'Jackson'});
});

it('narrows filter and resets when filter chain is altered', function(){
expect(pivot.data().raw.length).toEqual(6);
expect(pivot.data().all.length).toEqual(0);

// apply filter
pivot.filters().apply({last_name: 'Jackson'});
pivot.filters().apply();
expect(pivot.data().all.length).toEqual(3);

// apply additional filter
pivot.filters().apply({first_name: 'Jon'});
pivot.filters().add({first_name: 'Jon'});

// with no params simply runs existing filters
pivot.filters().apply()
expect(pivot.data().all.length).toEqual(1);

// reset original filter
Expand Down

0 comments on commit 8c92312

Please sign in to comment.