Skip to content

Instantly share code, notes, and snippets.

@chrisronline
Created October 25, 2013 19:14
Show Gist options
  • Save chrisronline/7160244 to your computer and use it in GitHub Desktop.
Save chrisronline/7160244 to your computer and use it in GitHub Desktop.
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