Skip to content

Commit dbeced5

Browse files
committed
refactor: update prettier command in package.json and pr-check yml
1 parent fb276ab commit dbeced5

15 files changed

+110
-57
lines changed

.github/workflows/typescript-pr-check.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ jobs:
2323

2424
- name: Install dependencies
2525
run: yarn install
26+
- name: Run Prettier
27+
run: yarn prettier
2628
- name: Run lint
2729
run: yarn lint
28-
- name: Run tests
29-
run: yarn pr-check
30+
- name: Run test
31+
run: yarn test
3032
- name: Run build
3133
run: yarn build

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"build:browser": "webpack",
2222
"build": "yarn build:types && yarn build:browser",
2323
"lint": "eslint . --ext .ts",
24-
"prettier": "prettier --write .",
24+
"prettier": "prettier --write '**/*.{ts,js}'",
2525
"pr-check": "yarn prettier && yarn lint && yarn build && yarn test"
2626
},
2727
"repository": {

tests/src/cpfValidator.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ describe("cpfIsValid", () => {
7575
let result = cpfIsValid("");
7676
expect(result.isValid).toBe(false);
7777

78-
expect(() => cpfIsValid(null as any)).toThrow("The input should be a string.");
78+
expect(() => cpfIsValid(null as any)).toThrow(
79+
"The input should be a string.",
80+
);
7981
});
8082

8183
it("should return isValid as false and the correct error message when CPF does not have 11 digits after cleaning", () => {

tests/src/getOnlyEmail.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,18 @@ describe("getOnlyEmail", () => {
9393
expect(result).toBe("alexa@google.com");
9494
});
9595

96-
it('should clean the domain from the email when cleanDomain is true', () => {
96+
it("should clean the domain from the email when cleanDomain is true", () => {
9797
const result = getOnlyEmail(
9898
"Entre em contato com a equipe: alexa@google.com.br",
99-
{ cleanDomain: true }
99+
{ cleanDomain: true },
100100
);
101101
expect(result).toBe("alexa@google.com.br");
102102
});
103103

104-
it('should clean the domain from the email using a custom domain list', () => {
104+
it("should clean the domain from the email using a custom domain list", () => {
105105
const result = getOnlyEmail(
106106
"Entre em contato com a equipe: alexa@google.custom",
107-
{ cleanDomain: [".custom"] }
107+
{ cleanDomain: [".custom"] },
108108
);
109109
expect(result).toBe("alexa@google.custom");
110110
});

tests/src/isAscii.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ describe("isAscii", () => {
77
});
88

99
it("should return true when the input is an empty string", () => {
10-
expect(() => isAscii(" ")).toThrow("Input value must not be an empty string.");
10+
expect(() => isAscii(" ")).toThrow(
11+
"Input value must not be an empty string.",
12+
);
1113
});
1214

1315
it("should return false when the input is not ASCII", () => {

tests/src/isDate.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ describe("isDate", () => {
1414
});
1515

1616
it("should throw an error when the input is a empty string", () => {
17-
expect(() => isDate("")).toThrow("Input value must not be an empty string.");
18-
expect(() => isDate(" ")).toThrow("Input value must not be an empty string.");
17+
expect(() => isDate("")).toThrow(
18+
"Input value must not be an empty string.",
19+
);
20+
expect(() => isDate(" ")).toThrow(
21+
"Input value must not be an empty string.",
22+
);
1923
});
2024

2125
it("should return false if isNaN or !(dateObject instanceof Date)", () => {

tests/src/isDecimal.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ describe("isDecimal", () => {
7373
});
7474

7575
it("should throw error when the input is a function", () => {
76-
function func() { /* document why this function 'func' is empty */ }
76+
function func() {
77+
/* document why this function 'func' is empty */
78+
}
7779

7880
expect(() => isDecimal(func() as any) as any).toThrow(errorToThrow);
7981
});
@@ -191,7 +193,9 @@ describe("isDecimal", () => {
191193
});
192194

193195
it("should throw error when the input is a function", () => {
194-
function func() { /* document why this function 'func' is empty */ }
196+
function func() {
197+
/* document why this function 'func' is empty */
198+
}
195199

196200
expect(() => isDecimal(func as any)).toThrow(
197201
"Input value must be a string or a number.",

tests/src/isValidVideo.test.ts

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -171,32 +171,56 @@ describe("isValidVideo", () => {
171171
expect(result1).toBe(false);
172172
});
173173

174-
test('validateMp4 should return true for specific byte sequence', () => {
174+
test("validateMp4 should return true for specific byte sequence", () => {
175175
const fileBuffer = Buffer.from([
176-
0x00, 0x00, 0x00, 0x18, // First 4 bytes
177-
0x66, 0x74, 0x79, 0x70 // Next 4 bytes
176+
0x00,
177+
0x00,
178+
0x00,
179+
0x18, // First 4 bytes
180+
0x66,
181+
0x74,
182+
0x79,
183+
0x70, // Next 4 bytes
178184
]);
179185

180186
const result = isValidVideo(fileBuffer);
181187
expect(result).toBe(true);
182188
});
183189

184-
test('validateMp4 should return true for byte sequence 1', () => {
190+
test("validateMp4 should return true for byte sequence 1", () => {
185191
const fileBuffer = Buffer.from([
186-
0x00, 0x00, 0x00, 0x20, // First 4 bytes
187-
0x66, 0x74, 0x79, 0x70, // Next 4 bytes
188-
0x6d, 0x70, 0x34, 0x32 // Last 4 bytes
192+
0x00,
193+
0x00,
194+
0x00,
195+
0x20, // First 4 bytes
196+
0x66,
197+
0x74,
198+
0x79,
199+
0x70, // Next 4 bytes
200+
0x6d,
201+
0x70,
202+
0x34,
203+
0x32, // Last 4 bytes
189204
]);
190205

191206
const result = isValidVideo(fileBuffer);
192207
expect(result).toBe(true);
193208
});
194209

195-
test('validateMp4 should return true for byte sequence 2', () => {
210+
test("validateMp4 should return true for byte sequence 2", () => {
196211
const fileBuffer = Buffer.from([
197-
0x00, 0x00, 0x00, 0x1c, // First 4 bytes
198-
0x66, 0x74, 0x79, 0x70, // Next 4 bytes
199-
0x69, 0x73, 0x6f, 0x6d // Last 4 bytes
212+
0x00,
213+
0x00,
214+
0x00,
215+
0x1c, // First 4 bytes
216+
0x66,
217+
0x74,
218+
0x79,
219+
0x70, // Next 4 bytes
220+
0x69,
221+
0x73,
222+
0x6f,
223+
0x6d, // Last 4 bytes
200224
]);
201225

202226
const result = isValidVideo(fileBuffer);

tests/src/validateEmail.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,21 @@ describe("validateEmail", () => {
8888

8989
it("should throw an error when errorMsg is not an array or null", () => {
9090
// @ts-ignore
91-
expect(() => validateEmail("jor@dio.com", { errorMsg: 123 })).toThrow("errorMsg must be an Array or null");
91+
expect(() => validateEmail("jor@dio.com", { errorMsg: 123 })).toThrow(
92+
"errorMsg must be an Array or null",
93+
);
9294
});
9395

9496
it("should throw an error if any element of the errorMsg array is different from string or null", () => {
95-
expect(() => validateEmail("jd@dio.com", { errorMsg: [123 as any] })).toThrow("All values within the array must be strings or null/undefined.");
96-
})
97+
expect(() =>
98+
validateEmail("jd@dio.com", { errorMsg: [123 as any] }),
99+
).toThrow("All values within the array must be strings or null/undefined.");
100+
});
97101

98102
it("should throw an error when maxLength must be a number and cannot be less than 1", () => {
99-
expect(() => validateEmail("aa@dao.com", { maxLength: 0 })).toThrow("maxLength must be a number and cannot be less than 1");
103+
expect(() => validateEmail("aa@dao.com", { maxLength: 0 })).toThrow(
104+
"maxLength must be a number and cannot be less than 1",
105+
);
100106
});
101107

102108
it("should invalidate an email that does not end with the country code", () => {
@@ -110,4 +116,4 @@ describe("validateEmail", () => {
110116
expect(result.isValid).toBe(true);
111117
expect(result.errorMsg).toBe(null);
112118
});
113-
});
119+
});

tests/src/validateName.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe("validateName", () => {
1111
const result: ValidateFunctions = validateName("");
1212
expect(result.isValid).toBe(false);
1313
expect(result.errorMsg).toBe("Name cannot be empty");
14-
});
14+
});
1515

1616
it("should return isValid as false for names with numbers", () => {
1717
const result: ValidateFunctions = validateName("John123");

0 commit comments

Comments
 (0)