Skip to content

Commit

Permalink
Add tests for SNFE initialization (gorhill#3823)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjethani authored Aug 15, 2021
1 parent f8f45ca commit 48d4f89
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions platform/npm/tests/snfe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit 48d4f89

Please sign in to comment.