I'm trying to create some test with Jasmine to test a web app.
how do you test content insert from the page? I created an example included: If i test the controller alone,with mocked data, the sum function provided in the example does work, but testing with the page, it causes an error because the numbers are converted to string, so, what is the correct approach to this kind of tests?
Here is an example i created to understand the problem i'm facing:
angular.module('MyApp', [])
.controller('provaController', function ($scope) {
$scope.firstNumber = 0;
$scope.secondNumber= 0;
$scope.result = 0;
$scope.sum = function() {
$scope.result = $scope.firstNumber + $scope.secondNumber;
};
});
<script src="http://ift.tt/1mQ03rn"></script>
<div ng-app="MyApp">
<div ng-controller="provaController">
<input type="text" ng-model="firstNumber" />
<input type="text" ng-model="secondNumber" />
<input type="button" ng-click="sum()" value="SUM"/>
<br/>
<input type="text" ng-model="result" />
<p>First: -{{firstNumber}}- </p>
<p>Sec: -{{secondNumber}}- </p>
<p>Res: -{{result}}- </p>
</div>
</div>
The pen example is here: http://ift.tt/1MkmilC
Aucun commentaire:
Enregistrer un commentaire