Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
fixed all testing
Browse files Browse the repository at this point in the history
  • Loading branch information
alannawalton committed Aug 17, 2017
1 parent acb298c commit 3c1c78f
Showing 1 changed file with 79 additions and 83 deletions.
162 changes: 79 additions & 83 deletions tests/popup-test.js
Expand Up @@ -21,98 +21,94 @@ const Validator = require('jsonschema').Validator;

const v = new Validator();

describe('isSupported(key)', function () {
describe('popup', function () {
describe('isSupported(key)', function () {

it('should return true when the key given is in the supported list', function () {
expect(popup.isSupported('Adhese')).to.be.true;
});
it('should return true when the key given is in the supported list', function () {
expect(popup.isSupported('Adhese')).to.be.true;
});

it('should return false when the key given is in NOT in the supported list', function () {
expect(popup.isSupported('alannalytics')).to.be.false;
it('should return false when the key given is in NOT in the supported list', function () {
expect(popup.isSupported('alannalytics')).to.be.false;
});
});
});

describe('addToDict(tempScript, htmlString, foundThis, key, category)', function () {

let htmlString;
let foundThis;

beforeEach(() => {
htmlString = 'candycanes';
foundThis = {
'supported': {
'ads': [],
'analytics': []
},
'notSupported': {
'ads': [],
'analytics': []
}
};
});
describe('addToDict(tempScript, htmlString, foundThis, key, category)', function () {

it('should push analytics to the analytics array', function () {
let tempScript = 'candy';
const category = 'Analytics';
let key = 'comScore';
popup.addToDict(tempScript, htmlString, foundThis, key, category);
expect(foundThis.supported.analytics).to.include('comScore');
tempScript = 'peppermint';
expect(foundThis.supported.analytics).to.not.include('Swoop');
expect(foundThis.notSupported.analytics).to.not.include('Swoop');
});
let htmlString;
let foundThis;

it('should push ads to the ads array', function () {
let tempScript = 'candy';
const category = 'Ads';
let key = 'comScore';
popup.addToDict(tempScript, htmlString, foundThis, key, category);
expect(foundThis.supported.ads).to.include('comScore');
tempScript = 'peppermint';
expect(foundThis.supported.ads).to.not.include('Swoop');
expect(foundThis.notSupported.ads).to.not.include('Swoop');
beforeEach(() => {
htmlString = 'candycanes';
foundThis = {
'supported': {
'ads': [],
'analytics': []
},
'notSupported': {
'ads': [],
'analytics': []
}
};
});

it('should push analytics to the analytics array', function () {
let tempScript = 'candy';
const category = 'Analytics';
let key = 'comScore';
popup.addToDict(tempScript, htmlString, foundThis, key, category);
expect(foundThis.supported.analytics).to.include('comScore');
tempScript = 'peppermint';
expect(foundThis.supported.analytics).to.not.include('Swoop');
expect(foundThis.notSupported.analytics).to.not.include('Swoop');
});

it('should push ads to the ads array', function () {
let tempScript = 'candy';
const category = 'Ads';
let key = 'comScore';
popup.addToDict(tempScript, htmlString, foundThis, key, category);
expect(foundThis.supported.ads).to.include('comScore');
tempScript = 'peppermint';
expect(foundThis.supported.ads).to.not.include('Swoop');
expect(foundThis.notSupported.ads).to.not.include('Swoop');
});
});
});

describe('vendors.json should be valid json', function () {

it('should be a valid file', function () {

let isJSONValid;

const vendorSchema = {
'id': '/SimpleVendors',
'type': 'object',
'properties': {
'regex': {
'type': 'array',
'items': {
describe('vendors.json should be valid json', function () {

it('should be a valid file', function () {

const vendorSchema = {
'id': '/SimpleVendors',
'type': 'object',
'properties': {
'regex': {
'type': 'array',
'items': {
'type': 'string'
}
},
'tooltip': {
'type': 'string'
}
},
'tooltip': {
'type': 'string'
},
'category': {
'type': 'string'
},
'category': {
'type': 'string'
},
},
},
'required': ['category', 'regex']
};

v.addSchema(vendorSchema, '/SimpleVendors');

const result = v.validate(vendors.vendor, vendorSchema);
const jsonObj = JSON.parse(JSON.stringify(vendors));

if (jsonObj && typeof jsonObj == 'object') {
isJSONValid = true;
}
else {
isJSONValid = false;
}

expect(isJSONValid).to.be.true;
expect(result.valid).to.be.true;
'required': ['category', 'regex']
};

v.addSchema(vendorSchema, '/SimpleVendors');

const result = v.validate(vendors.vendor, vendorSchema);
const jsonObj = JSON.parse(JSON.stringify(vendors));

const isJsonValid = (jsonObj && typeof jsonObj == 'object');


expect(isJsonValid).to.be.true;
expect(result.valid).to.be.true;
});
});
});

0 comments on commit 3c1c78f

Please sign in to comment.