I'm trying to unit test a method in Angularjs controllers using jasminejs and Karma runner my method takes an image path in the argument and transforms that image to text (TESSERACT-OCR).
when i try to call a unit test like this it does not work :
TypeError: Attempted to assign to readonly property. at workFn
it('has to return text from image', inject(function($httpBackend) {
$scope.ocr("./image.png");
$httpBackend.expectPOST('/ocr').respond();
expect( scope.oceriser.bind("./ocr.png")).toMatch("ocr");
}));
when i do the following:
it('has to return text from image', inject(function($httpBackend) {
$scope.ocr("./image.png");
$httpBackend.expectPOST('/ocr').respond();
expect($scope.ocr("./ocr.png")).toMatch("ocr");
}));
i get this error :
Expected undefined to match 'éàîè'.
can i access the $scope.textes.text value from the test ??
My question is how can i access the $scope.textes.text value that contains ocerised text from my test file ? is it possible i don't think because it is inside an anonymous function.. Is this a correct unit test ? can i have more coverage in this unit test ?can anyone help me i'm new in testing with jasmine