I am working on a Rails 3.2 application that will use AngularJS. I can get Angular to do what I need, but it is very difficult for me to figure out how to check what I am doing. I am using guard-jasmine to run Jasmine specs using PhantomJS.
Here is the (relevant) html:
<html id="ng-app" ng-app="app"> <div id="directive-element" class="directive-element"> </div> </html>
javascript (in coffeescript) looks like this:
window.Project = App: angular.module('app', []) Directive: {} Project.Directive.DirectiveElement = -> restrict: 'C' link: (scope, element, attrs) -> element.html 'hello world' Project.App.directive 'directiveElement', Project.Directive.DirectiveElement
The code above does exactly what it should do. Trials are a problem. I can not get them to work at all. This is one thing I have tried. Posting is basically just to start a conversation somewhere.
describe 'App.Directive.DirectiveElement', -> it 'updates directive-element', -> inject ($compile, $rootScope) -> element = $compile('<div id="app" ng-app="app"><div id="directive'element" class="directive-element"></div></div>') expect(element.text()).toEqual('hello world')
As an aside, I'm new to AngularJS, so if there are any best practices regarding namespaces, modules, etc. that I don't follow, the guide will be appreciated.
How do I get a test for this?
angularjs testing angularjs-directive
toadjamb Oct 05 2018-12-12T00: 00Z
source share