Propmt when a api key can not be use + house keeping (#173)
* chore: remove old files * chore: change JS tests to TS, delete dummy tests * chore: bump manifests version
This commit is contained in:
committed by
GitHub
parent
fe49f50b65
commit
35543489e5
12
tests/utils/Chrome.spec.ts
Normal file
12
tests/utils/Chrome.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import chai from 'chai';
|
||||
import sinon from 'sinon';
|
||||
import chrome from 'sinon-chrome';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('Chrome Dev Tools', function () {
|
||||
it('should work', function () {
|
||||
chrome.browserAction.setTitle({ title: 'hello' });
|
||||
sinon.assert.calledOnce(chrome.browserAction.setTitle);
|
||||
});
|
||||
});
|
||||
20
tests/utils/changeExtensionIcon.spec.ts
Normal file
20
tests/utils/changeExtensionIcon.spec.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import chai from 'chai';
|
||||
import changeExtensionIcon from '../../src/utils/changeExtensionIcon';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
jest.mock('webextension-polyfill', () => {
|
||||
return {
|
||||
runtime: {
|
||||
getManifest: () => {
|
||||
return { version: 'test-version' };
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe('changeExtensionIcon', function () {
|
||||
it('should be a function', function () {
|
||||
expect(changeExtensionIcon).to.be.a('function');
|
||||
});
|
||||
});
|
||||
20
tests/utils/changeExtensionState.spec.ts
Normal file
20
tests/utils/changeExtensionState.spec.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import chai from 'chai';
|
||||
import changeExtensionState from '../../src/utils/changeExtensionState';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
jest.mock('webextension-polyfill', () => {
|
||||
return {
|
||||
runtime: {
|
||||
getManifest: () => {
|
||||
return { version: 'test-version' };
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe('changeExtensionState', function () {
|
||||
it('should be a function', function () {
|
||||
expect(changeExtensionState).to.be.a('function');
|
||||
});
|
||||
});
|
||||
26
tests/utils/changeExtensionTooltip.spec.ts
Normal file
26
tests/utils/changeExtensionTooltip.spec.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import chai from 'chai';
|
||||
import changeExtensionTooltip from '../../src/utils/changeExtensionTooltip';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
jest.mock('webextension-polyfill', () => {
|
||||
return {
|
||||
runtime: {
|
||||
getManifest: () => {
|
||||
return { version: 'test-version' };
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe('changeExtensionTooltip', function () {
|
||||
it('should be a function', function () {
|
||||
expect(changeExtensionTooltip).to.be.a('function');
|
||||
});
|
||||
|
||||
// it('should change the extension tooltip', function() {
|
||||
// changeExtensionTooltip('WakaTime');
|
||||
// expect(chrome.browserAction.setTitle).toHaveBeenCalledWith({title: 'Wakatime'});
|
||||
// sinon.assert.calledWithMatch(chrome.browserAction.setTitle, {title: 'WakaTime'});
|
||||
// });
|
||||
});
|
||||
24
tests/utils/contains.spec.ts
Normal file
24
tests/utils/contains.spec.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import chai from 'chai';
|
||||
import contains from '../../src/utils/contains';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('contains', function () {
|
||||
it('should be a function', function () {
|
||||
expect(contains).to.be.a('function');
|
||||
});
|
||||
|
||||
it('should match url against blacklist and return true', function () {
|
||||
const list = 'localhost\ntest.com';
|
||||
|
||||
const url = 'http://localhost/fooapp';
|
||||
expect(contains(url, list)).to.equal(true);
|
||||
});
|
||||
|
||||
it('should not match url against blacklist and return false', function () {
|
||||
const list = 'localhost2\ntest.com';
|
||||
|
||||
const url = 'http://localhost/fooapp';
|
||||
expect(contains(url, list)).to.equal(false);
|
||||
});
|
||||
});
|
||||
23
tests/utils/getDomainFromUrl.spec.ts
Normal file
23
tests/utils/getDomainFromUrl.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import chai from 'chai';
|
||||
import getDomainFromUrl from '../../src/utils/getDomainFromUrl';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('getDomainFromUrl', function () {
|
||||
it('should be a function', function () {
|
||||
expect(getDomainFromUrl).to.be.a('function');
|
||||
});
|
||||
|
||||
it('should return the domain', function () {
|
||||
expect(getDomainFromUrl('http://google.com/something/very/secret')).to.equal(
|
||||
'http://google.com',
|
||||
);
|
||||
|
||||
expect(getDomainFromUrl('http://www.google.com/something/very/secret')).to.equal(
|
||||
'http://www.google.com',
|
||||
);
|
||||
|
||||
// This is not how it was imaged to work, but let's leave it here as a warning.
|
||||
expect(getDomainFromUrl('google.com/something/very/secret')).to.equal('google.com//very');
|
||||
});
|
||||
});
|
||||
18
tests/utils/in_array.spec.ts
Normal file
18
tests/utils/in_array.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import chai from 'chai';
|
||||
import inArray from '../../src/utils/inArray';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('inArray', function () {
|
||||
it('should be a function', function () {
|
||||
expect(inArray).to.be.a('function');
|
||||
});
|
||||
|
||||
it('should find the needle and return true', function () {
|
||||
expect(inArray('4', ['4', '3', '2', '1'])).to.equal(true);
|
||||
});
|
||||
|
||||
it('should not find the needle and it should return false', function () {
|
||||
expect(inArray('5', ['4', '3', '2', '1'])).to.equal(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user