Skip to content

Commit 65c52fe

Browse files
committed
formatting
1 parent 9cbf98a commit 65c52fe

File tree

3 files changed

+51
-19
lines changed

3 files changed

+51
-19
lines changed

src/build-request-url.test.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ describe('#buildRequestURL()', () => {
4141

4242
it('Complains if text and URL values are provided simultaneously', () => {
4343
expect(() =>
44-
buildRequestURL(
45-
{
46-
text: '.foo { text-align: center; }',
47-
// @ts-expect-error: We're trying to force an error here
48-
url: 'https://raw.githubusercontent.com/sparksuite/w3c-css-validator/master/public/css/valid.css',
49-
medium: undefined,
50-
warningLevel: undefined,
51-
}
52-
)
44+
buildRequestURL({
45+
text: '.foo { text-align: center; }',
46+
// @ts-expect-error: We're trying to force an error here
47+
url: 'https://raw.githubusercontent.com/sparksuite/w3c-css-validator/master/public/css/valid.css',
48+
medium: undefined,
49+
warningLevel: undefined,
50+
})
5351
).toThrow('Only a text or a URL value can be provided');
5452
});
5553
});

src/validate-url.test.ts

+42-8
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,35 @@ export default function testValidateURL(validateURL: ValidateURL): void {
1212
);
1313

1414
it('Returns the validity and errors when no options are provided', async () => {
15-
expect(await validateURL('https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/valid.css')).toStrictEqual({
15+
expect(
16+
await validateURL(
17+
'https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/valid.css'
18+
)
19+
).toStrictEqual({
1620
valid: true,
1721
errors: [],
1822
});
1923
});
2024

2125
it('Returns the validity, errors, and warnings when a warning level option is provided', async () => {
22-
expect(await validateURL('https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/valid.css', { warningLevel: 1 })).toStrictEqual({
26+
expect(
27+
await validateURL(
28+
'https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/valid.css',
29+
{ warningLevel: 1 }
30+
)
31+
).toStrictEqual({
2332
valid: true,
2433
errors: [],
2534
warnings: [],
2635
});
2736
});
2837

2938
it('Includes errors present in the response on the result', async () => {
30-
expect(await validateURL('https://rawcdn.githack.com/sparksuite/w3c-css-validator/76341fda26fd16021155ea853d6e4d7db0e194c4/public/css/error.css')).toStrictEqual({
39+
expect(
40+
await validateURL(
41+
'https://rawcdn.githack.com/sparksuite/w3c-css-validator/76341fda26fd16021155ea853d6e4d7db0e194c4/public/css/error.css'
42+
)
43+
).toStrictEqual({
3144
valid: false,
3245
errors: [
3346
{
@@ -42,7 +55,12 @@ export default function testValidateURL(validateURL: ValidateURL): void {
4255
});
4356

4457
it('Includes warnings present in the response on the result when options specify a warning level', async () => {
45-
expect(await validateURL('https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/warning.css', { warningLevel: 3 })).toStrictEqual({
58+
expect(
59+
await validateURL(
60+
'https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/warning.css',
61+
{ warningLevel: 3 }
62+
)
63+
).toStrictEqual({
4664
valid: true,
4765
errors: [],
4866
warnings: [
@@ -59,12 +77,21 @@ export default function testValidateURL(validateURL: ValidateURL): void {
5977
});
6078

6179
it('Does not include warnings on the result when warnings aren’t enabled', async () => {
62-
expect(await validateURL('https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/warning.css')).toStrictEqual({
80+
expect(
81+
await validateURL(
82+
'https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/warning.css'
83+
)
84+
).toStrictEqual({
6385
valid: true,
6486
errors: [],
6587
});
6688

67-
expect(await validateURL('https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/warning.css', { warningLevel: 0 })).toStrictEqual({
89+
expect(
90+
await validateURL(
91+
'https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/warning.css',
92+
{ warningLevel: 0 }
93+
)
94+
).toStrictEqual({
6895
valid: true,
6996
errors: [],
7097
});
@@ -82,11 +109,18 @@ export default function testValidateURL(validateURL: ValidateURL): void {
82109
});
83110

84111
it('Throws when the timeout is passed', async () => {
85-
await expect(validateURL('https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/valid.css', { timeout: 1 })).rejects.toThrow('The request took longer than 1ms');
112+
await expect(
113+
validateURL(
114+
'https://rawcdn.githack.com/sparksuite/w3c-css-validator/6cf7b194b4f0b246678ed5101a2b6f0fb2918361/public/css/valid.css',
115+
{ timeout: 1 }
116+
)
117+
).rejects.toThrow('The request took longer than 1ms');
86118
});
87119

88120
it('Parses out unwanted characters from error messages', async () => {
89-
const result = await validateURL('https://rawcdn.githack.com/sparksuite/w3c-css-validator/76341fda26fd16021155ea853d6e4d7db0e194c4/public/css/error.css');
121+
const result = await validateURL(
122+
'https://rawcdn.githack.com/sparksuite/w3c-css-validator/76341fda26fd16021155ea853d6e4d7db0e194c4/public/css/error.css'
123+
);
90124

91125
expect(result.errors.length).toBeGreaterThan(0);
92126
for (const error of result.errors) {

src/validate-url.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async function validateURL(urlToBeValidated: string, options?: Options): Promise
5959
result.errors.push({
6060
line: error.line,
6161
message: error.message.replace(/[ :]+$/, '').trim(),
62-
url: error.source ?? null,
62+
url: error.source ?? null,
6363
});
6464
});
6565

@@ -69,7 +69,7 @@ async function validateURL(urlToBeValidated: string, options?: Options): Promise
6969
line: warning.line,
7070
message: warning.message.replace(/[ :]+$/, '').trim(),
7171
level: (warning.level + 1) as 1 | 2 | 3,
72-
url: warning.source ?? null,
72+
url: warning.source ?? null,
7373
});
7474
});
7575
}

0 commit comments

Comments
 (0)