jasmine test running on jsFiddle
jsFiddle template to run a jasmine test inside jsFiddle. Adds jasmine external resources, and initializes jasmine's HtmlReporter on window load. For more infor check this article: http://opensas.wordpress.com/2013/06/23/sharing-you-javascript-ninja-secrets-run-your-jasmine-tests-on-jsfiddle/
by levrun
HTML
<link rel="stylesheet" href="//cdn.jsdelivr.net/jasmine/1.3.1/jasmine.css">
<script src="//cdn.jsdelivr.net/jasmine/1.3.1/jasmine.js"></script>
<script src="//cdn.jsdelivr.net/jasmine/1.3.1/jasmine-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.7.2/angular-translate.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.1/angular-mocks.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate-loader-url/2.7.2/angular-translate-loader-url.js"></script>
<title>Jasmine Spec Runner</title>
TypeScript
// specs code
/* jshint camelcase: false, unused: false */
/* global inject: false */
'use strict';
describe('pascalprecht.translate', function () {
describe('$translateUrlLoader', function () {
var $translate, $httpBackend, $translateUrlLoader, $translationCache;
beforeEach(module('pascalprecht.translate'));
beforeEach(inject(function (_$translate_, _$httpBackend_, _$translateUrlLoader_, _$translationCache_) {
$translate = _$translate_;
$httpBackend = _$httpBackend_;
$translateUrlLoader = _$translateUrlLoader_;
$translationCache = _$translationCache_;
$httpBackend.when('GET', 'foo/bar.json?lang=de_DE').respond({
it: 'works'
});
$httpBackend.when('GET', 'foo/bar.json?language=de_DE').respond({
it: 'works too'
});
}));
afterEach(function () {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});
it('should be defined', function () {
expect($translateUrlLoader).toBeDefined();
});
it('should be a function', function () {
expect(typeof $translateUrlLoader).toBe('function');
});
it('should fetch url when invoking', function () {
$httpBackend.expectGET('foo/bar.json?lang=de_DE');
$translateUrlLoader({
key: 'de_DE',
url: 'foo/bar.json'
});
$httpBackend.flush();
});
it('should use custom query parameter name when invoking with queryParameter', function () {
$httpBackend.expectGET('foo/bar.json?language=de_DE');
$translateUrlLoader({
key: 'de_DE',
url: 'foo/bar.json',
queryParameter: 'language'
});
$httpBackend.flush();
});
it('should put a translation table into a cache', function() {
$httpBackend.expectGET('foo/bar.json?lang=de_DE');
$translateUrlLoader({
key: 'de_DE',
url: 'foo/bar.json',
$http: {
cache: $translationCache
}
...