JSFiddle - React, Tailwind, and code Playground

by tmc4

HTML

<script src="https://code.angularjs.org/1.3.9/angular.min.js"></script>
<script src="https://cdn.jsdelivr.net/jasmine/1.3.1/jasmine.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/jasmine/1.3.1/jasmine.css">
<script src="https://cdn.jsdelivr.net/jasmine/1.3.1/jasmine-html.js"></script>
<script src="https://code.angularjs.org/1.2.9/angular-mocks.js"></script>

JavaScript

var mod = angular.module('myMod', []);

    mod.directive('newDir', function (){
        return {
            restrict:'E',
            scope:{
                myVal:'='
            },
            template:'<button ng-click="onClick(myVal)">my Button</button>{{myVal}}',
            controller:'newController'
            
        };
    }).controller('newController',['$scope',function($scope){
        var $this = this;
        $this.testMe = function(val){
             $scope.myVal = parseInt(val)+1;
        }
        
    }]);


describe('newDir', function(){
    var svc, 
        $rootScope,
        $scope,
        $compile,
        $httpBackend,
        $controller,
        ctrl;
    
    
     beforeEach(function () {
        module('myMod');
     });
    
     beforeEach(function () {
        inject(function (_$httpBackend_, _$controller_,_$rootScope_,_$compile_) {
            $httpBackend=_$httpBackend_;
            $controller = _$controller_;
            $rootScope = _$rootScope_;
            $compile = _$compile_;
            $scope = $rootScope.$new();
            var globalConfig = null;
            ctrl = $controller('newController', {'$rootScope': $rootScope, '$scope': $scope });
        });
    });
    
    it('testMe inc number', function() {
       
        ctrl.testMe(10)
        expect($scope.myVal).toEqual(11);
    });


});


// --- Runner -------------------------
//runner from http://jsfiddle.net/eitanp461/XrJMr/
(function () {
    var jasmineEnv = jasmine.getEnv();
    jasmineEnv.updateInterval = 1000;

    var htmlReporter = new jasmine.HtmlReporter();

    jasmineEnv.addReporter(htmlReporter);

    jasmineEnv.specFilter = function (spec) {
        return htmlReporter.specFilter(spec);
    };

    var currentWindowOnload = window.onload;

    window.onload = function () {
        if (currentWindowOnload) {
            currentWindowOnload();
        }
        execJasmine();
    };

    function execJasmine() {
        jasmineEnv.execute();
 ...