parent
cf0dcf2522
commit
efa1cb3967
11 changed files with 34 additions and 101 deletions
@ -1,15 +1,19 @@ |
||||
import messages from 'shared/messages'; |
||||
import actions from 'content/actions'; |
||||
|
||||
const enable = () => { |
||||
return { type: actions.ADDON_ENABLE }; |
||||
}; |
||||
const enable = () => setEnabled(true); |
||||
|
||||
const disable = () => { |
||||
return { type: actions.ADDON_DISABLE }; |
||||
}; |
||||
const disable = () => setEnabled(false); |
||||
|
||||
const toggleEnabled = () => { |
||||
return { type: actions.ADDON_TOGGLE_ENABLED }; |
||||
const setEnabled = async(enabled) => { |
||||
await browser.runtime.sendMessage({ |
||||
type: messages.ADDON_ENABLED_RESPONSE, |
||||
enabled, |
||||
}); |
||||
return { |
||||
type: actions.ADDON_SET_ENABLED, |
||||
enabled, |
||||
}; |
||||
}; |
||||
|
||||
export { enable, disable, toggleEnabled }; |
||||
export { enable, disable, setEnabled }; |
||||
|
@ -1,13 +1,13 @@ |
||||
import * as re from 'shared/utils/re'; |
||||
|
||||
const includes = (blacklist, url) => { |
||||
let u = new URL(url) |
||||
let u = new URL(url); |
||||
return blacklist.some((item) => { |
||||
if (!item.includes('/')) { |
||||
return re.fromWildcard(item).test(u.hostname); |
||||
} |
||||
return re.fromWildcard(item).test(u.hostname + u.pathname); |
||||
}); |
||||
} |
||||
}; |
||||
|
||||
export { includes }; |
||||
|
@ -1,25 +0,0 @@ |
||||
import actions from 'content/actions'; |
||||
import * as addonActions from 'content/actions/addon'; |
||||
|
||||
describe("addon actions", () => { |
||||
describe("enable", () => { |
||||
it('create ADDON_ENABLE action', () => { |
||||
let action = addonActions.enable(); |
||||
expect(action.type).to.equal(actions.ADDON_ENABLE); |
||||
}); |
||||
}); |
||||
|
||||
describe("disable", () => { |
||||
it('create ADDON_DISABLE action', () => { |
||||
let action = addonActions.disable(); |
||||
expect(action.type).to.equal(actions.ADDON_DISABLE); |
||||
}); |
||||
}); |
||||
|
||||
describe("toggle", () => { |
||||
it('create ADDON_TOGGLE_ENABLED action', () => { |
||||
let action = addonActions.toggleEnabled(); |
||||
expect(action.type).to.equal(actions.ADDON_TOGGLE_ENABLED); |
||||
}); |
||||
}); |
||||
}); |
Reference in new issue