Skip to content

Commit 6ae1acd

Browse files
test: ensure unit tests pass all
1 parent dce266b commit 6ae1acd

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

lib/utils/cpf.value-object.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ValueObject } from '../core';
22
import { Result } from '../core';
33
import isValidCpfDigit, {
44
formatValueToCpfPattern,
5+
removeSpecialCharsFromCpf,
56
} from './check-cpf-digit.util';
67
const regexCpf =
78
/^([0-9]{3})[\.]((?!\1)[0-9]{3})[\.]([0-9]{3})[-]([0-9]{2})$|^[0-9]{11}$/;
@@ -35,9 +36,11 @@ export class CPFValueObject extends ValueObject<Prop> {
3536
* @example after "52734865211"
3637
*/
3738
removeSpecialChars(): CPFValueObject {
38-
this.props.value = this.util
39-
.string(this.props.value)
40-
.removeSpecialChars();
39+
this.props.value = removeSpecialCharsFromCpf(this.props.value);
40+
41+
// this.props.value = this.util
42+
// .string(this.props.value)
43+
// .removeSpecialChars();
4144
return this;
4245
}
4346

@@ -59,10 +62,13 @@ export class CPFValueObject extends ValueObject<Prop> {
5962
* @example param "527.348.652-11"
6063
*/
6164
compare(cpf: string): boolean {
62-
const formattedCpf = this.util.string(cpf).removeSpecialChars();
63-
const instanceValue = this.util
64-
.string(this.props.value)
65-
.removeSpecialChars();
65+
// const formattedCpf = this.util.string(cpf).removeSpecialChars();
66+
// const instanceValue = this.util
67+
// .string(this.props.value)
68+
// .removeSpecialChars();
69+
70+
const formattedCpf = removeSpecialCharsFromCpf(cpf);
71+
const instanceValue = removeSpecialCharsFromCpf(this.props.value);
6672
return instanceValue === formattedCpf;
6773
}
6874

lib/utils/password.value-object.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ class PasswordValueObject extends ValueObject<Prop> {
106106
return true;
107107
}
108108

109+
isEqual(password: PasswordValueObject) {
110+
return this.compare(password.value());
111+
}
112+
109113
/**
110114
*
111115
* @param value password to create

lib/utils/user-name.value-object.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ export class UserNameValueObject extends ValueObject<Prop> {
3838
name[0].toUpperCase() + name.slice(1).toLowerCase();
3939
capitalized.push(lowerCaseName);
4040
}
41-
const value = this.util
42-
.string(capitalized.toString())
43-
.replace(',')
44-
.to(' ');
41+
42+
// const value = this.util
43+
// .string(capitalized.toString())
44+
// .replace(',')
45+
// .to(' ');
46+
47+
const value = capitalized.toString().replace(/,/g, ' ');
48+
4549
this.props.value = value;
4650
return this;
4751
}
@@ -98,10 +102,14 @@ export class UserNameValueObject extends ValueObject<Prop> {
98102
getInitials(): string {
99103
const names = this.props.value.split(' ');
100104
const letters = names.map((name) => name[0]);
101-
const initials = this.util
102-
.string(letters.toString())
103-
.replace(',')
104-
.to('.');
105+
106+
// const initials = this.
107+
// .string(letters.toString())
108+
// .replace(',')
109+
// .to('.');
110+
111+
const initials = letters.toString().replace(/,/g, '.');
112+
105113
return initials;
106114
}
107115

tests/utils/password.value-object.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ describe('password.value-object', () => {
7575
});
7676

7777
it('should password to be equal', () => {
78-
const passA = PasswordValueObject.random(12);
79-
const passB = passA.clone();
78+
const passA = PasswordValueObject.create('123456abc!').value();
79+
const passB = PasswordValueObject.create('123456abc!').value();
8080
const isEqual = passA.isEqual(passB);
8181
expect(isEqual).toBe(true);
8282
});

0 commit comments

Comments
 (0)