Skip to content

Instantly share code, notes, and snippets.

View anilcse's full-sized avatar
🎯
Focusing

Anil anilcse

🎯
Focusing
View GitHub Profile
@anilcse
anilcse / stateMock.js
Last active September 10, 2016 05:18 — forked from wilsonwc/stateMock.js
Angular Mock for properly resolving ui-router $state in Karma unit tests
angular.module('stateMock',[]);
angular.module('stateMock').service('$state', function ($q) {
this.expectedTransitions = [];
this.transitionTo = function(stateName) {
if(this.expectedTransitions.length) {
var expectedState = this.expectedTransitions.shift();
if (expectedState !== stateName) {
throw Error('Expected transition to state: ' + expectedState + ' but transitioned to ' + stateName);