Skip to content

Commit

Permalink
update to latest set
Browse files Browse the repository at this point in the history
  • Loading branch information
pemrouz committed Mar 28, 2016
1 parent f98582b commit 50d0799
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -14,8 +14,7 @@
"coveralls": "^2.11.2",
"istanbul": "^0.3.13",
"mocha": "^2.2.4",
"mocha-lcov-reporter": "0.0.2",
"versioned": "*"
"mocha-lcov-reporter": "0.0.2"
},
"dependencies": {
"utilise.is": "*",
Expand Down
21 changes: 6 additions & 15 deletions test.js
@@ -1,6 +1,6 @@
var versioned = require('versioned').default
, expect = require('chai').expect
var expect = require('chai').expect
, last = require('utilise.last')
, set = require('utilise.set')
, pop = require('./')

describe('pop', function() {
Expand All @@ -10,25 +10,16 @@ describe('pop', function() {
})

it('should pop - versioned', function(){
var changes = []
, o = versioned(['foo']).on('log', function(diff){ changes.push(diff) })
var o = set()(['foo'])

expect(o).to.eql(['foo'])
expect(o.log.length).to.eql(1)
expect(last(o.log).diff).to.eql(undefined)
expect(last(o.log).value.toJS()).to.eql(['foo'])
expect(changes).to.eql([])

expect(pop(o)).to.eql(o)
expect(pop(o)).to.equal(o)
expect(o).to.eql([])
expect(o.log.length).to.eql(2)
expect(last(o.log).diff).to.eql({ key: '0', value: 'foo', type: 'remove' })
expect(last(o.log).value.toJS()).to.eql([])
expect(changes).to.eql(o.log.slice(1).map(d => d.diff))
expect(last(o.log)).to.eql({ key: '0', value: 'foo', type: 'remove', time: 1 })
})

it('should skip gracefully', function(){
expect(pop(versioned({}))).to.be.eql({})
expect(pop(set()({}))).to.be.eql({})
expect(pop({})).to.be.eql({})
expect(pop(true)).to.be.eql(true)
expect(pop(5)).to.be.eql(5)
Expand Down

0 comments on commit 50d0799

Please sign in to comment.