Created
September 21, 2011 12:21
-
-
Save lucassus/1231897 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
describe('when the code does not exists in the collection', function() { | |
var $browser; | |
beforeEach(function() { | |
$browser = scope.$service('$browser'); | |
}); | |
describe('when validation fails', function() { | |
beforeEach(function() { | |
var validationResponse = 'validation fail'; | |
$browser.xhr.expectPOST('/validate', { id: record.id, code: 'code-666' }). | |
respond(200, validationResponse); | |
validator.validate('code-666', validationDone); | |
$browser.xhr.flush(); | |
}); | |
it('should set validation message', function() { | |
expect(validationDone).toHaveBeenCalledWith('exists in database'); | |
}); | |
}); | |
describe('when validation pass', function() { | |
beforeEach(function() { | |
var validationResponse = null; | |
$browser.xhr.expectPOST('/validate', { id: record.id, code: 'code-666' }). | |
respond(200, validationResponse); | |
validator.validate('code-666', validationDone); | |
$browser.xhr.flush(); | |
}); | |
it('should set validation message via hxr', function() { | |
expect(validationDone).toHaveBeenCalledWith(false); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment