Skip to content

Commit

Permalink
fix error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jellizaveta committed Dec 3, 2024
1 parent 3c808c1 commit b3a10e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions __tests__/filters-downloader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@ const FilterCompilerConditionsConstants = {

describe('FiltersDownloader', () => {
describe('error message during `!#include` and condition directives resolving', () => {
it('condition end not found', async () => {
it('unexpected condition else branch', async () => {
const rules = [
'always_included_rule',
'!#if (adguard)',
'!#else',
'if_adguard_included_rule',
];

expect(() => FiltersDownloader.resolveConditions(
rules,
FilterCompilerConditionsConstants,
)).toThrowError(new Error(`Invalid directives: Condition end not found '!#if (adguard)'
)).toThrowError(new Error(`Found unexpected condition else branch: '!#else'
Context:
\talways_included_rule
\t!#if (adguard)
\t!#else
`));
});

it('unexpected condition end', async () => {
const rules = [
'always_included_rule',
Expand All @@ -55,6 +57,7 @@ Context:
\t!#endif
`));
});

it('failed to resolve the include directive', async () => {
const rules = [
'always_included_rule',
Expand All @@ -76,6 +79,7 @@ Context:
`),
);
});

it('failed to resolve the include directive without file path', async () => {
const rules = [
'always_included_rule',
Expand All @@ -98,7 +102,8 @@ Context:
`),
);
});
it('failed to resolve the include directive without file path', async () => {

it('failed to resolve the include directive with 404 path', async () => {
const rules = [
'always_included_rule',
'||example.org^',
Expand Down
2 changes: 1 addition & 1 deletion src/filters-downloader-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ const FiltersDownloaderCreator = (FileDownloadWrapper: IFileDownloader): IFilter
} else if (rule.indexOf(CONDITION_ELSE_DIRECTIVE_START) === 0) {
// Found !#else without !#if
errorMessage = createErrorMessage(
'Invalid directives: Found unexpected condition else branch:',
'Found unexpected condition else branch:',
rule,
context,
urlOrigin,
Expand Down

0 comments on commit b3a10e9

Please sign in to comment.