Last active
December 30, 2016 09:15
-
-
Save chrisjaure/6515906 to your computer and use it in GitHub Desktop.
AngularJS Jasmine test snippets for Sublime Text 2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
describe('${1:SuiteName}', function() { | |
var scope, \$httpBackend, initController; | |
beforeEach(function() { | |
module('${2:ModuleName}', function(\$provide){ | |
}); | |
inject(function(\$injector) { | |
var \$rootScope, \$controller; | |
\$rootScope = \$injector.get('\$rootScope'); | |
\$controller = \$injector.get('\$controller'); | |
\$httpBackend = \$injector.get('\$httpBackend'); | |
scope = \$rootScope.\$new(); | |
initController = function(opts) { | |
\$controller('${3:ControllerName}', angular.extend({ | |
\$scope: scope | |
}, (opts || {}))); | |
}; | |
}); | |
}); | |
afterEach(function() { | |
// \$httpBackend.verifyNoOutstandingExpectation(); | |
// \$httpBackend.verifyNoOutstandingRequest(); | |
scope.\$destroy(); | |
}); | |
it('should pass', function() { | |
// \$httpBackend.expectGET('').respond(200); | |
initController(); | |
}); | |
}); | |
]]></content> | |
<tabTrigger>ng:test:c</tabTrigger> | |
<scope>source.js</scope> | |
</snippet> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
describe('${1:SuiteName}', function() { | |
var elm, scope, isolateScope, | |
html = '${3:<div>Element Template</div>}'; | |
beforeEach(function() { | |
module('${2:ModuleName}', function(\$provide){ | |
}); | |
inject(function(\$injector) { | |
var \$compile, \$templateCache, \$rootScope; | |
\$compile = \$injector.get('\$compile'); | |
\$rootScope = \$injector.get('\$rootScope'); | |
// \$templateCache = \$injector.get('\$templateCache'); | |
// \$templateCache.put('${4:templateUrl}', '<div></div>'); | |
elm = angular.element(html); | |
scope = \$rootScope.\$new(); | |
\$compile(elm)(scope); | |
scope.\$digest(); | |
// isolateScope = elm.isolateScope(); | |
}); | |
}); | |
afterEach(function() { | |
scope.\$destroy(); | |
}); | |
it('should pass', function() { | |
}); | |
}); | |
]]></content> | |
<tabTrigger>ng:test:d</tabTrigger> | |
<scope>source.js</scope> | |
</snippet> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
describe('${1:SuiteName}', function() { | |
var ${3:ServiceName}, scope; | |
beforeEach(function() { | |
module('${2:ModuleName}', function(\$provide){ | |
}); | |
inject(function(\$injector) { | |
var \$rootScope; | |
\$rootScope = \$injector.get('\$rootScope'); | |
${3:ServiceName} = \$injector.get('${3:ServiceName}'); | |
scope = \$rootScope.\$new(); | |
}); | |
}); | |
afterEach(function() { | |
scope.\$destroy(); | |
}); | |
it('should pass', function() { | |
}); | |
}); | |
]]></content> | |
<tabTrigger>ng:test:s</tabTrigger> | |
<scope>source.js</scope> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment