JSFiddle - React, Tailwind, and code Playground

by unludo

HTML

<script src="http://daniellmb.github.io/jasmine-run/jasmine-1.3.1-run.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-mocks.js"></script>

JavaScript

angular.module('myApp', [])
.directive('myTest', function () {
    return {
        restrict: 'E',
        scope: { message: '='},
        replace: true,
        template:  '<div ng-if="message"><p>{{message}}</p></div>',
        link: function (scope, element, attrs) {
        }
    };
});

describe('myTest directive:', function () {
    
    var scope, compile, validHTML;
    
    validHTML = '<my-test message="message"></my-test>';
    
    beforeEach(module('myApp'));
    
    beforeEach(inject(function($compile, $rootScope){
        scope = $rootScope.$new();
        compile = $compile;
    }));
    
    function create() {
        var elem, compiledElem;
        elem = angular.element(validHTML);
        compiledElem = compile(elem)(scope);
        scope.$digest();

        return compiledElem;    
    }
    
    it('should have a scope on root element', function () {  
        scope.message = 'not empty';
        var el = create();
        console.log(el.text());
        expect(el.text()).toBeDefined();
        expect(el.text()).not.toBe('');
    });
    
});