Skip to content

Commit de49344

Browse files
committed
Chore: Change code samples following the Runkit pattern
1 parent 9bca1c4 commit de49344

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ Teste e aprenda <a href="https://npm.runkit.com/cep-promise" target="_blank">aqu
4949
Por ser multifornecedor, a biblioteca irá resolver a Promise com o fornecedor que **mais rápido** lhe responder.
5050

5151
``` js
52-
import cep from 'cep-promise'
52+
import cepPromise from 'cep-promise'
5353

54-
cep('05010000')
54+
cepPromise('05010000')
5555
.then(console.log)
5656

5757
// {
@@ -69,10 +69,10 @@ cep('05010000')
6969
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:
7070

7171
``` js
72-
import cep from 'cep-promise'
72+
import cepPromise from 'cep-promise'
7373

7474
// enviando sem ter um zero à esquerda do CEP "05010000"
75-
cep(5010000)
75+
cepPromise(5010000)
7676
.then(console.log)
7777

7878
// {
@@ -89,9 +89,9 @@ cep(5010000)
8989
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.
9090

9191
``` js
92-
import cep from 'cep-promise'
92+
import cepPromise from 'cep-promise'
9393

94-
cep('99999999')
94+
cepPromise('99999999')
9595
.catch(console.log)
9696

9797
// {
@@ -114,9 +114,9 @@ cep('99999999')
114114
Neste caso será retornado um `"validation_error"` e a biblioteca irá rejeitar imediatamente a Promise, sem chegar a consultar nenhum fornecedor.
115115

116116
``` js
117-
import cep from 'cep-promise'
117+
import cepPromise from 'cep-promise'
118118

119-
cep('123456789123456789')
119+
cepPromise('123456789123456789')
120120
.catch(console.log)
121121

122122
// {
@@ -160,7 +160,7 @@ $ yarn add cep-promise
160160
``` ts
161161
import * as cep from 'cep-promise'
162162

163-
cep('05010000')
163+
cepPromise('05010000')
164164
.then(console.log)
165165
```
166166

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"zipcode",
3636
"zip",
3737
"promise",
38-
"viacep"
38+
"viacep",
39+
"cepPromise"
3940
],
4041
"homepage": "https://github.com/filipedeschamps/cep-promise",
4142
"devDependencies": {

test/e2e/cep-promise.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import chaiAsPromised from 'chai-as-promised'
55
import chaiSubset from 'chai-subset'
66
import nock from 'nock'
77

8-
import cep from '../../src/cep-promise.js'
8+
import cepPromise from '../../src/cep-promise.js'
99
import CepPromiseError from '../../src/errors/cep-promise.js'
1010

1111
chai.use(chaiAsPromised)
@@ -17,9 +17,9 @@ describe('[e2e] cep-promise', () => {
1717
before(() => {
1818
nock.enableNetConnect()
1919
})
20-
20+
2121
describe('when invoked with a valid "05010000" string', () => {
22-
it('should fulfill with correct address', () => cep('05010000')
22+
it('should fulfill with correct address', () => cepPromise('05010000')
2323
.then(address => {
2424
expect(address).to.deep.equal({
2525
cep: '05010000',
@@ -34,7 +34,7 @@ describe('[e2e] cep-promise', () => {
3434

3535
describe('when invoked with a valid 05010000 number', () => {
3636
it('should fulfill with correct address', async () => {
37-
const address = await cep(5010000)
37+
const address = await cepPromise(5010000)
3838

3939
expect(address).to.deep.equal({
4040
cep: '05010000',
@@ -49,7 +49,7 @@ describe('[e2e] cep-promise', () => {
4949

5050
describe('when invoked with an inexistent "99999999" CEP', () => {
5151
it('should reject with "service_error"', () => {
52-
return cep('99999999').catch(error => {
52+
return cepPromise('99999999').catch(error => {
5353
return expect(error)
5454
.to.be.an.instanceOf(CepPromiseError)
5555
.and.containSubset({
@@ -82,7 +82,7 @@ describe('[e2e] cep-promise', () => {
8282

8383
describe('when invoked with an invalid "123456789" CEP', () => {
8484
it('should reject with "validation_error"', () => {
85-
return cep('123456789').catch(error => {
85+
return cepPromise('123456789').catch(error => {
8686
return expect(error)
8787
.to.be.an.instanceOf(CepPromiseError)
8888
.and.containSubset({

0 commit comments

Comments
 (0)