Skip to content

Instantly share code, notes, and snippets.

@pporche87
Created April 18, 2017 01:05
Show Gist options
  • Save pporche87/9956e0ae30898d346e09e1d7a66b6bf4 to your computer and use it in GitHub Desktop.
Save pporche87/9956e0ae30898d346e09e1d7a66b6bf4 to your computer and use it in GitHub Desktop.
import chai, { expect } from 'chai'
import chaiChange from 'chai-change'
import Node from '../src/node'
chai.use(chaiChange)
describe('Node', () => {
const nodeA = new Node({data: 'apple'})
const nodeB = new Node({data: 'banana'})
it('checks to see if Node is a function', () => {
expect(Node).to.be.a('function')
})
context('getData()', () => {
it('returns the data ("apple") of the node', () => {
nodeA.getData()
expect(nodeA.data.data).to.equal('apple')
})
})
context('setNext()', () => {
it('changes the reference to the next node and returns the original node', () => {
nodeA.setNext(nodeB)
expect(nodeA.next.data.data).to.equal('banana')
})
})
context('getNext()', () => {
it('returns the next node', () => {
expect(nodeA.getNext(nodeB) ).to.equal(nodeA.next)
})
it('return null if no next node', () => {
expect(nodeA.getNext() ).to.equal(null)
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment