Mocha Chai Expect

by quangcanh2975

HTML

<link rel="stylesheet" href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css">
<script src="https://cdn.rawgit.com/Automattic/expect.js/0.3.1/index.js"></script>
<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/3.3.0/chai.min.js"></script>
<!-- Mocha test output goes here. -->
<div id="mocha"></div>

JavaScript

mocha.setup('bdd');
var expect = chai.expect;

// Given an array of numbers, return a new array that only includes the even numbers.
function evensOnly(arr) {
	return arr.filter(function(x){
  	return x % 2 ==0;
  });
}

describe('first', function () {
	it('case 1', function () {
    expect(evensOnly([3, 6, 8, 2])).to.eql([6, 8, 2]);
  });
  it('case 2', function () {
    expect(evensOnly([1, 5, 5])).to.eql([]);
  });
});

mocha.run();