import { expect } from '../../test'

import {
  getCategories,
  getTotalCosts,
  getCostsPerCategory,
  getCostsPerMonth,
  getCostsPerMonthAndCategory
} from './costFunctions'

describe('Cost functions', () => {
  const costs = {
    1: { category: 'Food', cost: 1, time: new Date('01-01-2016') },
    2: { category: 'Food', cost: 2, time: new Date('01-01-2016') },
    3: { category: 'Rent', cost: 2, time: new Date('02-02-2016') }
  }

  describe('getCategories', () => {
    it('should extract all categories', () => {
      expect(getCategories(costs)).to.be.deep.equal(
        ['Food', 'Rent']
      )
    })
  })

  describe('getTotalCosts', () => {
    it('should sum up all costs', () => {
      expect(getTotalCosts(costs)).to.be.equal(5)
    })
  })

  describe('getCostsPerCategory', () => {
    it('should group all costs per category', () => {
      expect(getCostsPerCategory(costs)).to.be.deep.equal([
        {category: 'Food', cost: 3},
        {category: 'Rent', cost: 2}
      ])
    })
  })

  describe('getCostsPerMonth', () => {
    it('should group all costs per category', () => {
      expect(getCostsPerMonth(costs)).to.be.deep.equal({
        January: [
          {category: 'Food', cost: 1, time: new Date('01-01-2016')},
          {category: 'Food', cost: 2, time: new Date('01-01-2016')}
        ],
        February: [
          {category: 'Rent', cost: 2, time: new Date('02-02-2016')}
        ]
      })
    })
  })

  describe('getCostsPerMonthAndCategory', () => {
    it('should group all costs per category', () => {
      expect(getCostsPerMonthAndCategory(costs)).to.be.deep.equal({
        January: [
          {category: 'Food', cost: 3}
        ],
        February: [
          {category: 'Rent', cost: 2}
        ]
      })
    })
  })
})

@@ -1078,32 +1078,29 @@
 l costs per 
-category
+month
 ', () =%3E %7B%0A 

Fix typo