Permalink
Browse files

Merge branch 'master' of github.com:rjackson/pivot.js

  • Loading branch information...
Robert Jackson
Robert Jackson committed Mar 27, 2012
2 parents 9fdee08 + 72aad43 commit 8c92312447de710edb43cfd180409b2cf3efdec7
Showing with 14 additions and 3 deletions.
  1. +14 −3 spec/pivotjs_spec.js
View
@@ -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'});
@@ -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

0 comments on commit 8c92312

Please sign in to comment.