1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

Add tests for SNFE initialization (#3823)

This commit is contained in:
Manish Jethani 2021-08-15 20:46:57 +05:30 committed by GitHub
parent f8f45cab70
commit 48d4f890d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,36 @@ process.on('warning', warning => {
let engine = null;
describe('SNFE', () => {
describe('Initialization', () => {
let StaticNetFilteringEngine = null;
beforeEach(async () => {
const module = await createWorld('./index.js', { globals: { URL } });
StaticNetFilteringEngine = module.StaticNetFilteringEngine;
});
it('should not reject on first attempt', async () => {
await StaticNetFilteringEngine.create();
});
it('should reject on second attempt', async () => {
await StaticNetFilteringEngine.create();
await assert.rejects(StaticNetFilteringEngine.create());
});
it('should reject on third attempt', async () => {
await StaticNetFilteringEngine.create();
try {
await StaticNetFilteringEngine.create();
} catch (error) {
}
await assert.rejects(StaticNetFilteringEngine.create());
});
});
describe('Filter loading', () => {
beforeEach(async () => {
const globals = { URL, setTimeout, clearTimeout };