Skip to content

Instantly share code, notes, and snippets.

@weekens
Created March 20, 2018 08:56
Show Gist options
  • Save weekens/5bd8ebb6c7d2d73b2f8554aeeb59d323 to your computer and use it in GitHub Desktop.
Save weekens/5bd8ebb6c7d2d73b2f8554aeeb59d323 to your computer and use it in GitHub Desktop.
Unit test for prime finder actor.
describe('PrimeFinderActor', () => {
it('should correctly find next prime', () => {
const pf = new PrimeFinderActor();
expect(pf.nextPrime(1)).to.be.equal(2);
expect(pf.nextPrime(2)).to.be.equal(3);
expect(pf.nextPrime(3)).to.be.equal(5);
expect(pf.nextPrime(30)).to.be.equal(31);
});
it('should only accept positive numbers', () => {
const pf = new PrimeFinderActor();
expect(() => pf.nextPrime(0)).to.throw();
expect(() => pf.nextPrime(-1)).to.throw();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment