-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from modos189/fix-external
Bug fix when re-adding an external plugin
- Loading branch information
Showing
6 changed files
with
269 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3 | ||
|
||
import { describe, it, before } from 'mocha'; | ||
import { Manager } from '../src/manager.js'; | ||
import storage from '../test/storage.js'; | ||
import { expect } from 'chai'; | ||
|
||
describe('manage.js base integration tests', function () { | ||
let manager = null; | ||
before(function () { | ||
const params = { | ||
storage: storage, | ||
channel: 'beta', | ||
network_host: { | ||
release: 'http://127.0.0.1:31606/release', | ||
beta: 'http://127.0.0.1:31606/beta', | ||
custom: 'http://127.0.0.1/', | ||
}, | ||
inject_user_script: function callBack(data) { | ||
expect(data).to.include('// ==UserScript=='); | ||
}, | ||
progressbar: function callBack(is_show) { | ||
expect(is_show).to.be.oneOf([true, false]); | ||
}, | ||
is_daemon: false, | ||
}; | ||
manager = new Manager(params); | ||
}); | ||
|
||
describe('run', function () { | ||
it('Should not return an error', async function () { | ||
const run = await manager.run(); | ||
expect(run).to.be.undefined; | ||
}); | ||
}); | ||
|
||
describe('Check channel', function () { | ||
it('Should return beta', async function () { | ||
const channel = await storage.get(['channel']).then((data) => data.channel); | ||
expect(channel).to.equal('beta'); | ||
}); | ||
}); | ||
|
||
describe('setChannel', function () { | ||
it('Should not return an error', async function () { | ||
const channel = await manager.setChannel('release'); | ||
expect(channel).to.be.undefined; | ||
}); | ||
}); | ||
|
||
describe('setUpdateCheckInterval', function () { | ||
it('Should not return an error', async function () { | ||
const fn = await manager.setUpdateCheckInterval(24 * 60 * 60, 'release'); | ||
expect(fn).to.be.undefined; | ||
}); | ||
}); | ||
|
||
describe('inject', function () { | ||
it('Should not return an error', async function () { | ||
const inject = await manager.inject(); | ||
expect(inject).to.be.undefined; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3 | ||
|
||
import { describe, it, before } from 'mocha'; | ||
import { Manager } from '../src/manager.js'; | ||
import storage from '../test/storage.js'; | ||
import { expect } from 'chai'; | ||
|
||
describe('manage.js build-in plugins integration tests', function () { | ||
let manager = null; | ||
before(function () { | ||
const params = { | ||
storage: storage, | ||
channel: 'release', | ||
network_host: { | ||
release: 'http://127.0.0.1:31606/release', | ||
beta: 'http://127.0.0.1:31606/beta', | ||
custom: 'http://127.0.0.1/', | ||
}, | ||
inject_user_script: function callBack(data) { | ||
expect(data).to.include('// ==UserScript=='); | ||
}, | ||
progressbar: function callBack(is_show) { | ||
expect(is_show).to.be.oneOf([true, false]); | ||
}, | ||
is_daemon: false, | ||
}; | ||
manager = new Manager(params); | ||
}); | ||
|
||
const first_plugin_uid = 'Available AP statistics+https://github.com/IITC-CE/ingress-intel-total-conversion'; | ||
const second_plugin_uid = 'Bing maps+https://github.com/IITC-CE/ingress-intel-total-conversion'; | ||
|
||
describe('run', function () { | ||
it('Should not return an error', async function () { | ||
const run = await manager.run(); | ||
expect(run).to.be.undefined; | ||
}); | ||
}); | ||
|
||
describe('Manage build-in plugins', function () { | ||
it('Enable first plugin', async function () { | ||
const run = await manager.managePlugin(first_plugin_uid, 'on'); | ||
expect(run).to.be.undefined; | ||
|
||
const db_data = await storage.get(['release_plugins_flat', 'release_plugins_local']); | ||
expect(db_data['release_plugins_flat'], 'release_plugins_flat').to.have.all.keys(first_plugin_uid, second_plugin_uid); | ||
expect(db_data['release_plugins_local'], 'release_plugins_local').to.have.all.keys(first_plugin_uid); | ||
|
||
expect(db_data['release_plugins_local'][first_plugin_uid]['status'], 'release_plugins_local: ' + first_plugin_uid).to.equal('on'); | ||
expect(db_data['release_plugins_flat'][first_plugin_uid]['status'], 'release_plugins_flat: ' + first_plugin_uid).to.equal('on'); | ||
expect(db_data['release_plugins_flat'][second_plugin_uid]['status'], 'release_plugins_flat: ' + second_plugin_uid).to.equal('off'); | ||
}); | ||
|
||
it('Enable second plugin', async function () { | ||
const run = await manager.managePlugin(second_plugin_uid, 'on'); | ||
expect(run).to.be.undefined; | ||
|
||
const db_data = await storage.get(['release_plugins_flat', 'release_plugins_local']); | ||
expect(db_data['release_plugins_flat'], 'release_plugins_flat').to.have.all.keys(first_plugin_uid, second_plugin_uid); | ||
expect(db_data['release_plugins_local'], 'release_plugins_local').to.have.all.keys(first_plugin_uid, second_plugin_uid); | ||
|
||
expect(db_data['release_plugins_local'][first_plugin_uid]['status'], 'release_plugins_local: ' + first_plugin_uid).to.equal('on'); | ||
|
||
expect(db_data['release_plugins_local'][second_plugin_uid]['status'], 'release_plugins_local: ' + second_plugin_uid).to.equal('on'); | ||
|
||
expect(db_data['release_plugins_flat'][first_plugin_uid]['status'], 'release_plugins_flat: ' + first_plugin_uid).to.equal('on'); | ||
|
||
expect(db_data['release_plugins_flat'][second_plugin_uid]['status'], 'release_plugins_flat: ' + second_plugin_uid).to.equal('on'); | ||
}); | ||
|
||
it('Disable plugin', async function () { | ||
const run = await manager.managePlugin(first_plugin_uid, 'off'); | ||
expect(run).to.be.undefined; | ||
|
||
const db_data = await storage.get(['release_plugins_flat', 'release_plugins_local']); | ||
expect(db_data['release_plugins_flat'], 'release_plugins_flat').to.have.all.keys(first_plugin_uid, second_plugin_uid); | ||
expect(db_data['release_plugins_local'], 'release_plugins_local').to.have.all.keys(first_plugin_uid, second_plugin_uid); | ||
|
||
expect(db_data['release_plugins_local'][first_plugin_uid]['status'], 'release_plugins_local: ' + first_plugin_uid).to.equal('off'); | ||
|
||
expect(db_data['release_plugins_local'][second_plugin_uid]['status'], 'release_plugins_local: ' + second_plugin_uid).to.equal('on'); | ||
|
||
expect(db_data['release_plugins_flat'][first_plugin_uid]['status'], 'release_plugins_flat: ' + first_plugin_uid).to.equal('off'); | ||
|
||
expect(db_data['release_plugins_flat'][second_plugin_uid]['status'], 'release_plugins_flat: ' + second_plugin_uid).to.equal('on'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.