angular-viacep
Version:
Angular Module for integration WebService ViaCep created by César Barone <cesar.bmcosta@gmail.com>
38 lines (28 loc) • 1.03 kB
text/coffeescript
describe 'angular-viacep::cep', ->
beforeEach ->
module 'angular.viacep'
beforeEach inject ( _viaCep_, _$http_) ->
= _viaCep_
= _$http_
describe 'for invalid CEP', ->
it 'throw error for empty cep', ->
expect(.get).toThrowError("CEP can't be undefined")
it 'throw error for empty cep', ->
f = () =>
.get('')
expect(f).toThrowError("CEP can't be empty")
it 'throw error for null cep', ->
f = () =>
.get(null)
expect(f).toThrowError("CEP can't be null")
describe 'for valid CEP', ->
beforeEach ->
spyOn(, 'get').and.callThrough()
= '89160000'
= "https://viacep.com.br/ws/#{@formatedCep}/json/"
it 'calls $http get method for non formated cep', ->
.get('89160-000')
expect(.get).toHaveBeenCalledWith()
it 'calls $http get method for formated cep', ->
.get()
expect(.get).toHaveBeenCalledWith()