-
Notifications
You must be signed in to change notification settings - Fork 7
/
cnpj_test.go
41 lines (34 loc) · 1.24 KB
/
cnpj_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package brdocs_test
import (
"github.com/brazanation/go-documents"
"github.com/brazanation/go-documents/internal/test"
"testing"
)
func TestCnpjShouldBeValid(t *testing.T) {
cnpj, err := brdocs.NewCnpj("99999090910270")
internal_test.AssertValidDocument(t, cnpj, err)
}
func TestCnpjShouldBeSameType(t *testing.T) {
cnpj, _ := brdocs.NewCnpj("99999090910270")
internal_test.AssertDocumentType(t, cnpj, brdocs.CnpjType)
}
func TestCnpjShouldBeFormatted(t *testing.T) {
cnpj, err := brdocs.NewCnpj("99999090910270")
internal_test.AssertValidDocument(t, cnpj, err)
internal_test.AssertDocumentFormatted(t, cnpj, "99.999.090/9102-70")
}
func TestCnpjShouldReturnErrorForRepeatedNumber(t *testing.T) {
number := "11111111111111"
_, err := brdocs.NewCnpj(number)
internal_test.AssertNotValidDocument(t, number, err, "Cnpj(11111111111111) is invalid")
}
func TestCnpjShouldReturnErrorForInvalidNumber(t *testing.T) {
number := "00111222100099"
_, err := brdocs.NewCnpj(number)
internal_test.AssertNotValidDocument(t, number, err, "Cnpj(00111222100099) is invalid")
}
func TestCnpjShouldReturnErrorForEmptyNumber(t *testing.T) {
number := ``
_, err := brdocs.NewCnpj(number)
internal_test.AssertNotValidDocument(t, number, err, "Cnpj must not be empty")
}