You need to use $document in the code everywhere instead of document, and add an injection to your test class like this:
beforeEach(inject([
'CookiesService', '$document', function(_CookiesService_, _$document_) {
CookiesService = _CookiesService_;
$document = _$document_;
}
]));
Here's a plunker showing a working test: http://plnkr.co/edit/GaO8wBMoBd8BGXaIkzf8?p=preview