Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it ('should reject if authentication has not been performed', function(done) {
var host = {
_getAuth: sinon.stub().returns({
isAuthenticated: sinon.stub().returns(Promise.reject())
})
};
var options = {
timestamp: 1435054283,
expires_in: 21600,
channel: "/conversation/2256621",
signature: "7d2018df16bd7686063483c8960124bc0a1bb0e2"
};
var subscription = pushLib.push.call(host, options).subscribe(new Function());
subscription.then(function(){
// Should not be called
expect('Authentication should not pass').toBe(false);
}).catch(function(err) {
find(cep) {
if (this.validateCep(cep)) {
return this.webMania(cep)
.catch(() => this.viaCep(cep));
}
return Promise.reject(false);
}
handleWebmania(response) {
if (response.data.uf === '') {
return Promise.reject('CEP não encontrado');
}
let data = response.data;
const estado = this.getState(data.uf);
data = Object.assign({}, data, { estado });
return data;
}
handleViaCep(response) {
const data = response.data;
if (response.status !== 200 || data.erro) {
return Promise.reject('CEP não encontrado');
}
const estado = this.getState(data.uf);
return {
cep: data.cep,
endereco: data.logradouro,
bairro: data.bairro,
cidade: data.localidade,
estado,
uf: data.uf,
};
}
handleError() {
return Promise.reject('CEP não encontrado');
}