forked from sayanee/angularjs-pdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add few unit test for ng-pdf directive
- add karma-ng-html2js-preprocessor dependance to use viewer template - add karma.proxies to serve the pdf file maybe help sayanee#79
- Loading branch information
Showing
3 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
describe('ngPdf', function() { | ||
console.log = function() {}; | ||
var element, $scope; | ||
|
||
// Load the myApp module, which contains the directive | ||
beforeEach(module('App')); | ||
|
||
beforeEach(module('my.templates')); | ||
|
||
beforeEach(inject(function(_$compile_, _$rootScope_, _$document_){ | ||
// The injector unwraps the underscores (_) from around the parameter names when matching | ||
var $compile = _$compile_; | ||
var $rootScope = _$rootScope_; | ||
var $document = _$document_; | ||
$scope = $rootScope.$new(); | ||
// Compile a piece of HTML containing the directive | ||
var html = '<ng-pdf template-url="partials/viewer.html" canvasid="pdf" scale="page-fit" page=13></ng-pdf>'; | ||
var elmnt = angular.element(html); | ||
$document.find('body').append(elmnt); | ||
element = $compile(elmnt)($scope); | ||
$scope.pdfUrl = '/pdf/relativity.pdf'; | ||
$scope.$digest(); | ||
})); | ||
|
||
beforeEach(function(done){ | ||
setTimeout(function() { | ||
done(); | ||
}, 9000); | ||
}, 10000); | ||
|
||
it('ng-pdf maust have 1 canvas', function() { | ||
var canvas = element.find('canvas'); | ||
expect(canvas.length).toBe(1); | ||
}); | ||
|
||
it('goNext and goPrevious change page', function(){ | ||
expect($scope.pageNum).toBe(13); | ||
$scope.goPrevious(); | ||
expect($scope.pageNum).toBe(12); | ||
$scope.goNext(); | ||
expect($scope.pageNum).toBe(13); | ||
}); | ||
}); |