'use strict';

var expect = require('chai').expect;
var angular = require('angular');

var helloWorldModule = require('./helloWorld.controller');
var calculatorModule = require('../services/calculator/calculator.service');

describe('helloWorld', function() {
	var $controller;
	var mockCalculator;

	beforeEach(function() {
		angular.mock.module(helloWorldModule.moduleName);

		mockCalculator = {
			calculateResult: null,
			calculate: sinon.spy(function() { return mockCalculator.calculateResult; }),
		};

		angular.mock.module(function ($provide) {
			$provide.value(calculatorModule.factoryName, mockCalculator);
		});

		angular.mock.inject(['$controller', function(_$controller_) {
			$controller = _$controller_;
		}]);
	});

	it ('should have a message', function() {
		var controller = buildController();
		expect(controller.message).to.equal('Hello Angular explorers!')
	});

	function buildController() {
		return $controller(helloWorldModule.controllerName);
	}
});

@@ -732,17 +732,16 @@
 %7D);%0A%0A%09it
- 
 ('should
@@ -881,16 +881,512 @@
 )%0A%09%7D);%0A%0A
+%09it('should calculate the result of the operands and operator', function() %7B%0A%09%09var controller = buildController();%0A%0A%09%09controller.operand1 = 5;%0A%09%09controller.operand2 = 10;%0A%09%09controller.operator = '*';%0A%09%09mockCalculator.calculateResult = 'mocked result';%0A%0A%09%09controller.equals();%0A%0A%09%09expect(controller.result).to.equal('mocked result');%0A%09%09expect(controller.error).to.be.null;%0A%0A%09%09sinon.assert.calledOnce(mockCalculator.calculate);%0A%09%09sinon.assert.calledWith(mockCalculator.calculate, '*', 5, 10);%0A%09%7D);%0A%0A
 %09functio

Add a test to verify that the controller calls the calculator service properly.