我正在尝试从我的 vuex 商店测试以下非常简单的 getter。它只是连接两个字符串:
const getters = {
adressToGet: state => {
return state.baseAdress + store.getters.queryToGet
}
}
Run Code Online (Sandbox Code Playgroud)
嘲笑州部分很容易,但我找不到嘲笑商店的好方法。
如果这是在一个组件中,我可以使用mount或shallow来安装该组件并为其分配模拟存储,但事实并非如此。这是来自 vuex 商店。
这是我的测试代码:
import Search from '@/store/modules/search'
jest.mock('@/store/modules/search.js')
describe('search.js', () => {
test('The adress getter gets the right adress', () => {
const state = {
baseAdress: 'http://foobar.com/'
}
// I define store here, but how can I inject it into my tested getter ?
const store = {
getters: {
queryToGet: 'barfoo'
}
}
expect(Search.getters.adressToGet(state)).toBe('http://foobar.com/barfoo') …Run Code Online (Sandbox Code Playgroud) 我现在正在学习HTML/CSS,所以我做了一点点cookie-clicker看起来很有趣:http://jsfiddle.net/Zerh/6kb87sp9/
我的问题是:如果我在任何按钮上点击太快(双击),它会突出显示一个选项.我使用以下CSS来隐藏突出显示:
::selection {
background: transparent;
}
::-moz-selection {
background: transparent;
}
Run Code Online (Sandbox Code Playgroud)
它似乎适用于Firefox/Edge,但我不能让它在Chrome上运行.
我发现了这个老话题:如何使用CSS禁用文本选择突出显示?,但它已经6岁了,似乎对我不起作用.