title: Testing dates in JS
body: <p>date.js
  </p>
  
  <pre><code>class DateHelper {
    constructor() {
      this.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
    }
  
    postedOn(from) {
      const date = new Date(from);
      const day = date.getDate();
      const month = this.months[date.getMonth()];
      const year = date.getFullYear();
      if (year === new Date().getFullYear()) {
        return `${day} ${month}`;
      }
      return `${day} ${month} ${year}`;
    }
  }
  </code></pre>
  
  <p>date_spec.js
  </p>
  
  <pre><code>describe('', () =&gt; {
    it('', () =&gt; {
      const from = 'Wed Feb 25 2015 00:38:24 GMT+0200 (EET)';
      expect(newDateHelper.postedOn(from)).to.equal('25 Feb 2015');
    });
    it('', () =&gt; {
      const from = 'Wed Feb 25 2017 00:38:24 GMT+0200 (EET)';
      expect(newDateHelper.postedOn(from)).to.equal('25 Feb');
    });
  });
  </code></pre>
  
  <p>All tests are currently passing, but because <code>postedOn</code> compares to the current year I will need to update those tests each year. How can I fix this?</p>