Skip to content

Commit

Permalink
adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Komorski authored and Marcin Komorski committed Jul 17, 2024
1 parent 523f281 commit a6dba4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/idImportLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ let email;
let conf;
const LOG_PRE_FIX = 'ID-Library: ';
const CONF_DEFAULT_OBSERVER_DEBOUNCE_MS = 250;
const CONF_DEFAULT_FULL_BODY_SCAN = false;
const CONF_DEFAULT_INPUT_SCAN = false;
export const CONF_DEFAULT_FULL_BODY_SCAN = false;
export const CONF_DEFAULT_INPUT_SCAN = false;
const OBSERVER_CONFIG = {
subtree: true,
attributes: true,
Expand Down
14 changes: 14 additions & 0 deletions test/spec/modules/idImportLibrary_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import * as idImportlibrary from 'modules/idImportLibrary.js';
import {getGlobal} from '../../../src/prebidGlobal.js';
import {config} from 'src/config.js';
import {hook} from '../../../src/hook.js';
import * as activities from '../../../src/activities/rules.js';
import { ACTIVITY_ENRICH_UFPD } from '../../../src/activities/activities.js';
import { CONF_DEFAULT_FULL_BODY_SCAN, CONF_DEFAULT_INPUT_SCAN } from '../../../modules/idImportLibrary.js';

var expect = require('chai').expect;

const mockMutationObserver = {
Expand Down Expand Up @@ -86,6 +90,16 @@ describe('IdImportLibrary Tests', function () {
idImportlibrary.setConfig(config);
expect(config.inputscan).to.be.equal(true);
});
it('results when activity is not allowed', function () {
sandbox.stub(activities, 'isActivityAllowed').callsFake((activity) => {
return !(activity === ACTIVITY_ENRICH_UFPD);
});
let config = { 'url': 'URL', 'debounce': 0 };
idImportlibrary.setConfig(config);
sinon.assert.called(utils.logError);
expect(config.inputscan).to.be.not.equal(CONF_DEFAULT_INPUT_SCAN);
expect(config.fullscan).to.be.not.equal(CONF_DEFAULT_FULL_BODY_SCAN);
});
});
describe('Test with email is found', function () {
let mutationObserverStub;
Expand Down

0 comments on commit a6dba4d

Please sign in to comment.