I know you can load, compile and test an Angular directive something like so:
it('Replaces the element with the appropriate content', function () {
var element = $compile("<my-directive></my-directive>")($rootScope);
$rootScope.$digest();
expect(element).toContain("some HTML...");
});
Is there a way to do exactly the same but loading and compiling an HTML fragment (from a file) instead of having to create a directive? The fragment is just an ngRepeat and an ngController - wrapping this into a directive is just an added layer of unnecessary complexity, but I'd still like to be able to test the generated HTML.
For example, for an HTML partial `my-table.html':
<table class="table table-condensed table-striped" data-ng-controller="MyController">
<tbody>
<tr data-ng-repeat="item in myItems">
...
I'd have a Jasmine test that looked something like:
it('Replaces the element with the appropriate content', function () {
var element = $compile("my-table.html")($rootScope);
$rootScope.$digest();
expect(element).toContain("some HTML...");
});