From de49344633ba02c8a3c21e2d8541c5b4c949755c Mon Sep 17 00:00:00 2001 From: Leandro Nunes Date: Wed, 14 Oct 2020 13:52:28 -0300 Subject: [PATCH] Chore: Change code samples following the Runkit pattern --- README.md | 18 +++++++++--------- package.json | 3 ++- test/e2e/cep-promise.spec.js | 12 ++++++------ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 0c2a70b..adafbc6 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,9 @@ Teste e aprenda aqu Por ser multifornecedor, a biblioteca irá resolver a Promise com o fornecedor que **mais rápido** lhe responder. ``` js -import cep from 'cep-promise' +import cepPromise from 'cep-promise' -cep('05010000') +cepPromise('05010000') .then(console.log) // { @@ -69,10 +69,10 @@ cep('05010000') Em muitos sistemas o CEP é utilizado erroneamente como um Inteiro (e com isto cortando todos os zeros à esquerda). Caso este seja o seu caso, não há problema, pois a biblioteca irá preencher os caracteres faltantes na String, por exemplo: ``` js -import cep from 'cep-promise' +import cepPromise from 'cep-promise' // enviando sem ter um zero à esquerda do CEP "05010000" -cep(5010000) +cepPromise(5010000) .then(console.log) // { @@ -89,9 +89,9 @@ cep(5010000) Neste caso será retornado um `"service_error"` e por ser multifornecedor, a biblioteca irá rejeitar a Promise apenas quando tiver a resposta negativa de todos os fornecedores. ``` js -import cep from 'cep-promise' +import cepPromise from 'cep-promise' -cep('99999999') +cepPromise('99999999') .catch(console.log) // { @@ -114,9 +114,9 @@ cep('99999999') Neste caso será retornado um `"validation_error"` e a biblioteca irá rejeitar imediatamente a Promise, sem chegar a consultar nenhum fornecedor. ``` js -import cep from 'cep-promise' +import cepPromise from 'cep-promise' -cep('123456789123456789') +cepPromise('123456789123456789') .catch(console.log) // { @@ -160,7 +160,7 @@ $ yarn add cep-promise ``` ts import * as cep from 'cep-promise' -cep('05010000') +cepPromise('05010000') .then(console.log) ``` diff --git a/package.json b/package.json index 849ef68..e07a123 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "zipcode", "zip", "promise", - "viacep" + "viacep", + "cepPromise" ], "homepage": "https://github.com/filipedeschamps/cep-promise", "devDependencies": { diff --git a/test/e2e/cep-promise.spec.js b/test/e2e/cep-promise.spec.js index ee4ff0d..50a4999 100644 --- a/test/e2e/cep-promise.spec.js +++ b/test/e2e/cep-promise.spec.js @@ -5,7 +5,7 @@ import chaiAsPromised from 'chai-as-promised' import chaiSubset from 'chai-subset' import nock from 'nock' -import cep from '../../src/cep-promise.js' +import cepPromise from '../../src/cep-promise.js' import CepPromiseError from '../../src/errors/cep-promise.js' chai.use(chaiAsPromised) @@ -17,9 +17,9 @@ describe('[e2e] cep-promise', () => { before(() => { nock.enableNetConnect() }) - + describe('when invoked with a valid "05010000" string', () => { - it('should fulfill with correct address', () => cep('05010000') + it('should fulfill with correct address', () => cepPromise('05010000') .then(address => { expect(address).to.deep.equal({ cep: '05010000', @@ -34,7 +34,7 @@ describe('[e2e] cep-promise', () => { describe('when invoked with a valid 05010000 number', () => { it('should fulfill with correct address', async () => { - const address = await cep(5010000) + const address = await cepPromise(5010000) expect(address).to.deep.equal({ cep: '05010000', @@ -49,7 +49,7 @@ describe('[e2e] cep-promise', () => { describe('when invoked with an inexistent "99999999" CEP', () => { it('should reject with "service_error"', () => { - return cep('99999999').catch(error => { + return cepPromise('99999999').catch(error => { return expect(error) .to.be.an.instanceOf(CepPromiseError) .and.containSubset({ @@ -82,7 +82,7 @@ describe('[e2e] cep-promise', () => { describe('when invoked with an invalid "123456789" CEP', () => { it('should reject with "validation_error"', () => { - return cep('123456789').catch(error => { + return cepPromise('123456789').catch(error => { return expect(error) .to.be.an.instanceOf(CepPromiseError) .and.containSubset({