import ivoryDice from '../src/ivory-dice.js';

describe('ivoryDice', () => {
	it('should return the result of calling the generator function', () => {
		let result = ivoryDice((min, max) => 3);
		expect(result).to.equal(3);
	});

	it('should throw on violation of generator function minimum constraints', () => {
		expect(ivoryDice.bind({}, (min, max) => min - 1)).to.throw();
	});

	it('should throw on violation of generator function maximum constraints', () => {
		expect(ivoryDice.bind({}, (min, max) => max + 1)).to.throw();
	});

	it('should throw on violation of generator integer constraint by receiving a floating point number', () => {
		expect(ivoryDice.bind({}, (min, max) => min + 0.5)).to.throw();
	});

	it('should throw on violation of generator integer constraint by receiving a non-numeric type', () => {
		expect(ivoryDice.bind({}, (min, max) => '1')).to.throw();
	});

	it('should throw on violation of input constraint by receiving a number of sides < 1', () => {
		expect(ivoryDice.bind({}, (min, max) => '1', 0)).to.throw();
	});
});

@@ -40,16 +40,130 @@
 e.js';%0A%0A
+function expectInvalidGeneratorToBreakContract(generator)%7B%0A%09expect(ivoryDice.bind(%7B%7D, generator)).to.throw();%0A%7D;%0A%0A
 describe
@@ -329,32 +329,77 @@
 equal(3);%0A%09%7D);%0A%0A
+%09describe('the generator contract', () =%3E %7B%0A%09
 %09it('should thro
@@ -471,34 +471,47 @@
 %7B%0A%09%09
+%09
 expect
-(ivoryDice.bind(%7B%7D, 
+InvalidGeneratorToBreakContract(
 (min
@@ -528,36 +528,26 @@
 min - 1)
-).to.throw()
 ;%0A
+%09
 %09%7D);%0A%0A
+%09
 %09it('sho
@@ -627,40 +627,52 @@
 %7B%0A%09%09
+%09
 expect
-(ivoryDice.bind(%7B%7D, 
+InvalidGeneratorToBreakContract(
 (min,
- 
 max)
@@ -683,36 +683,26 @@
 max + 1)
-).to.throw()
 ;%0A
+%09
 %09%7D);%0A%0A
+%09
 %09it('sho
@@ -809,34 +809,47 @@
 %7B%0A%09%09
+%09
 expect
-(ivoryDice.bind(%7B%7D, 
+InvalidGeneratorToBreakContract(
 (min
@@ -868,36 +868,26 @@
 n + 0.5)
-).to.throw()
 ;%0A
+%09
 %09%7D);%0A%0A
+%09
 %09it('sho
@@ -989,34 +989,47 @@
 %7B%0A%09%09
+%09
 expect
-(ivoryDice.bind(%7B%7D, 
+InvalidGeneratorToBreakContract(
 (min
@@ -1046,28 +1046,18 @@
 '1')
-).to.throw()
 ;%0A
+%09
 %09%7D);%0A%0A
+%09
 %09it(
@@ -1150,16 +1150,17 @@
  =%3E %7B%0A%09%09
+%09
 expect(i
@@ -1191,19 +1191,19 @@
 max) =%3E 
-'1'
+min
 , 0)).to
@@ -1212,16 +1212,22 @@
 hrow();%0A
+%09%09%7D);%0A
 %09%7D);%0A%7D);

Refactor specification.