Skip to content

Instantly share code, notes, and snippets.

@donabrams
Created July 16, 2015 16:50
Show Gist options
  • Save donabrams/3f42e7017170b52593f5 to your computer and use it in GitHub Desktop.
Save donabrams/3f42e7017170b52593f5 to your computer and use it in GitHub Desktop.
Tests for transducer protocol support for Immutable.js
/*global describe, it */
let {expect} = require('chai');
let {Map, List, Set, Stack} = require('immutable');
let t2 = require('transduce');
describe('Immutable Transducer support', ()=> {
it('List supports transducer protocols', () => {
let val = t2.into(List(), t2.filter(()=>true), ['a', 'b', 'c']).toJS();
expect(val).to.deep.equal(['a', 'b', 'c']);
});
it('Set support transducer protocols', () => {
let val = t2.into(Set(), t2.filter(()=>true), ['a', 'b', 'c', 'b']).toJS();
expect(val).to.deep.equal(['a', 'b', 'c']);
});
it('Map support transducer protocols', () => {
let val = t2.into(Map(), t2.filter(()=>true), {'a':1, 'b':2, 'c':3}).toJS();
expect(val).to.deep.equal({'a':1, 'b':2, 'c':3});
});
it('Stack support transducer protocols', () => {
let val = t2.into(Stack(), t2.filter(()=>true), ['a', 'b', 'c']).toJS();
expect(val).to.deep.equal(['c', 'b', 'a']);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment