Created
October 25, 2013 19:14
-
-
Save chrisronline/7160244 to your computer and use it in GitHub Desktop.
This file contains 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
it('test', function() { | |
spyOn(dialog, 'dialog').andCallFake(function(opts) { | |
var options = opts.resolve.options(); | |
expect(options.title).toBe('Error'); | |
expect(options.fields[0]).toBe('name'); | |
expect(options.showRequired).toBe(false); | |
// If you look at showError, it calls dialog.dialog | |
// and expects an object returned that has a 'open' method | |
// so mock that out so the real controller does not | |
// throw an error | |
return { open: angular.noop }; | |
}); | |
// Setup for the test, simulate an error | |
// by populating the scope with what would | |
// be there if such an error occurred | |
scope.steps.one = { | |
form: { | |
$error: { | |
required: [ | |
{ | |
$name: 'name' | |
} | |
] | |
} | |
} | |
}; | |
// Call our trigger function | |
scope.steps.goTo(2); | |
// Ensure our spy is called so our expect tests within run | |
expect(dialog.dialog).toHaveBeenCalled(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment