-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update the tests and add a check for rules not in the base syntax
- Loading branch information
1 parent
d18e4b8
commit a31621b
Showing
4 changed files
with
82 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { optimizeBaseRules } = require('../../main/utils/builder-utils'); | ||
|
||
jest.mock('../../main/utils/log'); | ||
|
||
describe('optimizeBaseRules options of include directive', () => { | ||
it('Properly removes redundant rules', () => { | ||
const lines = [ | ||
'||example.com^', | ||
'||sub.example.com^', | ||
'||sub2.sub.example.com^', | ||
'||anotherexample.com^', | ||
]; | ||
const expectedOutput = ['||example.com^', '||anotherexample.com^']; | ||
const result = optimizeBaseRules(lines); | ||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('Returns all rules if there are no redundant rules', () => { | ||
const lines = [ | ||
'||example.com^', | ||
'||anotherexample.com^', | ||
]; | ||
const expectedOutput = ['||example.com^', '||anotherexample.com^']; | ||
const result = optimizeBaseRules(lines); | ||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('Skips rules that should not be optimized', () => { | ||
const lines = [ | ||
'||example.com^', | ||
'||sub.example.com^', | ||
'||sub2.sub.example.com^', | ||
'||some.anotherexample.com^', | ||
'||anotherexample.com^$image', | ||
'host.com', | ||
]; | ||
const expectedOutput = [ | ||
'||example.com^', | ||
'||some.anotherexample.com^', | ||
'||anotherexample.com^$image', | ||
'host.com', | ||
]; | ||
const result = optimizeBaseRules(lines); | ||
expectedOutput.forEach((rule) => { | ||
expect(result.includes(rule)).toBeTruthy(); | ||
}); | ||
}); | ||
}); |