Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Change code samples following the Runkit pattern #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ Teste e aprenda <a href="https://npm.runkit.com/cep-promise" target="_blank">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)

// {
Expand All @@ -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)

// {
Expand All @@ -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)

// {
Expand All @@ -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)

// {
Expand Down Expand Up @@ -160,7 +160,7 @@ $ yarn add cep-promise
``` ts
import * as cep from 'cep-promise'

cep('05010000')
cepPromise('05010000')
.then(console.log)
```

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"zipcode",
"zip",
"promise",
"viacep"
"viacep",
"cepPromise"
],
"homepage": "https://github.com/filipedeschamps/cep-promise",
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/cep-promise.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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({
Expand Down Expand Up @@ -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({
Expand Down