Skip to content

Commit

Permalink
Refactored sinon spy definitions out of the test blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhenry committed Jul 15, 2015
1 parent 43c6869 commit bafcfba
Showing 1 changed file with 37 additions and 18 deletions.
55 changes: 37 additions & 18 deletions app/src/app/guest/login/login.spec.ts
Expand Up @@ -35,42 +35,61 @@ describe('Login', () => {

});

it('should resolve the dialog when login credentials are passed', () => {
describe('dialog interactions', () => {

sinon.spy($mdDialog, 'hide');
beforeEach(() => {

let creds = {
username: 'foo',
password: 'bar',
};
sinon.spy($mdDialog, 'hide');
sinon.spy($mdDialog, 'cancel');
sinon.spy($mdDialog, 'show');

(<any>$scope).login(creds.username, creds.password);
});

expect($mdDialog.hide).to.have.been.calledWith(creds);
afterEach(() => {

});
(<any>$mdDialog).hide.restore();
(<any>$mdDialog).cancel.restore();
(<any>$mdDialog).show.restore();

it('should cancel dialog when requested', () => {
});

sinon.spy($mdDialog, 'cancel');
it('should resolve the dialog when login credentials are passed', () => {

(<any>$scope).cancelLoginDialog();

expect($mdDialog.cancel).to.have.been.called;
let creds = {
username: 'foo',
password: 'bar',
};

(<any>$scope).login(creds.username, creds.password);

expect($mdDialog.hide).to.have.been.calledWith(creds);

});

it('should cancel dialog when requested', () => {

});

it('should show the login dialog when prompted', () => {
(<any>$scope).cancelLoginDialog();

sinon.spy($mdDialog, 'show');
expect($mdDialog.cancel).to.have.been.called;

authService.getPromisedUser(); //@todo change this to a promptLogin() method (not yet implemented in package)
});

expect($mdDialog.show).to.have.been.called;
it('should show the login dialog when prompted', () => {


authService.getPromisedUser(); //@todo change this to a promptLogin() method (not yet implemented in package)

expect($mdDialog.show).to.have.been.called;

});

});




});

});

0 comments on commit bafcfba

Please sign in to comment.