I'm trying to test an angular module that I can't modify. It grabs data from the dom sadly, so I have to mock it or else null error. I've created an empty HTML document, but I'm having trouble adding elements to it properly.
Using jQuery instead of $. (noConflict(), not my choice)
describe('...', function () {
var $body;
beforeEach(function () {
var doc;
doc = document.implementation.createHTMLDocument();
$body = jQuery(doc.body);
var input = jQuery('<input/>',{id:'appURL', value:'//localhost:3005});
angular.mock.module('myApp', function ($provide) {
$provide.value('$document', jQuery(doc));
});
});
});
Aucun commentaire:
Enregistrer un commentaire