fix tests
This commit is contained in:
parent
54298927da
commit
ff621d9d80
12 changed files with 78 additions and 63 deletions
|
|
@ -6,7 +6,7 @@ import { nextTick } from 'vue'
|
|||
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
||||
import { $t, mountOpts, waitForEvent } from '../../../fixtures/setup_test'
|
||||
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||
|
||||
const autoSaveOrNot = (caseFn, caseTitle, runFn) => {
|
||||
caseFn(`${caseTitle} with auto-save`, function () {
|
||||
|
|
@ -48,7 +48,7 @@ describe('Draft saving', () => {
|
|||
'should save when the button is clicked',
|
||||
async (autoSave) => {
|
||||
const wrapper = mount(PostStatusForm, mountOpts())
|
||||
const store = useSyncConfigStore()
|
||||
const store = useMergedConfigStore()
|
||||
store.mergedConfig = {
|
||||
autoSaveDraft: autoSave,
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ describe('Draft saving', () => {
|
|||
it('should auto-save if it is enabled', async function () {
|
||||
vi.useFakeTimers()
|
||||
const wrapper = mount(PostStatusForm, mountOpts())
|
||||
const store = useSyncConfigStore()
|
||||
const store = useMergedConfigStore()
|
||||
store.mergedConfig = {
|
||||
autoSaveDraft: true,
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ describe('Draft saving', () => {
|
|||
},
|
||||
}),
|
||||
)
|
||||
const store = useSyncConfigStore()
|
||||
const store = useMergedConfigStore()
|
||||
store.mergedConfig = {
|
||||
autoSaveDraft: true,
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ describe('Draft saving', () => {
|
|||
},
|
||||
}),
|
||||
)
|
||||
const store = useSyncConfigStore()
|
||||
const store = useMergedConfigStore()
|
||||
store.mergedConfig = {
|
||||
autoSaveDraft: false,
|
||||
unsavedPostAction: 'save',
|
||||
|
|
@ -134,7 +134,7 @@ describe('Draft saving', () => {
|
|||
},
|
||||
}),
|
||||
)
|
||||
const store = useSyncConfigStore()
|
||||
const store = useMergedConfigStore()
|
||||
store.mergedConfig = {
|
||||
autoSaveDraft: false,
|
||||
unsavedPostAction: 'discard',
|
||||
|
|
@ -156,7 +156,7 @@ describe('Draft saving', () => {
|
|||
},
|
||||
}),
|
||||
)
|
||||
const store = useSyncConfigStore(createTestingPinia())
|
||||
const store = useMergedConfigStore(createTestingPinia())
|
||||
store.mergedConfig = {
|
||||
autoSaveDraft: false,
|
||||
unsavedPostAction: 'confirm',
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ createTestingPinia()
|
|||
|
||||
import EmojiInput from 'src/components/emoji_input/emoji_input.vue'
|
||||
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||
|
||||
const generateInput = (value, padEmoji = true) => {
|
||||
const wrapper = shallowMount(EmojiInput, {
|
||||
|
|
@ -45,7 +45,7 @@ const generateInput = (value, padEmoji = true) => {
|
|||
|
||||
describe('EmojiInput', () => {
|
||||
beforeEach(() => {
|
||||
const store = useSyncConfigStore(createTestingPinia())
|
||||
const store = useMergedConfigStore(createTestingPinia())
|
||||
store.mergedConfig = {
|
||||
padEmoji: true,
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ describe('EmojiInput', () => {
|
|||
it('inserts string without any padding if padEmoji setting is set to false', () => {
|
||||
const initialString = 'Eat some spam!'
|
||||
const wrapper = generateInput(initialString, false)
|
||||
const store = useSyncConfigStore(createTestingPinia())
|
||||
const store = useMergedConfigStore(createTestingPinia())
|
||||
store.mergedConfig = {
|
||||
padEmoji: false,
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ describe('EmojiInput', () => {
|
|||
it('correctly sets caret after insertion if padEmoji setting is set to false', async () => {
|
||||
const initialString = '1234'
|
||||
const wrapper = generateInput(initialString, false)
|
||||
const store = useSyncConfigStore(createTestingPinia())
|
||||
const store = useMergedConfigStore(createTestingPinia())
|
||||
store.mergedConfig = {
|
||||
padEmoji: false,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import { cloneDeep } from 'lodash'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
|
||||
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
|
||||
|
||||
import {
|
||||
_getAllFlags,
|
||||
_getRecentData,
|
||||
|
|
@ -75,7 +73,7 @@ describe('The SyncConfig store', () => {
|
|||
_version: VERSION,
|
||||
flagStorage: {
|
||||
...defaultState.flagStorage,
|
||||
updateCounter: CURRENT_UPDATE_COUNTER,
|
||||
updateCounter: 1,
|
||||
},
|
||||
prefsStorage: {
|
||||
...defaultState.prefsStorage,
|
||||
|
|
@ -85,7 +83,7 @@ describe('The SyncConfig store', () => {
|
|||
|
||||
expect(store.flagStorage).to.eql({
|
||||
...defaultState.flagStorage,
|
||||
updateCounter: CURRENT_UPDATE_COUNTER,
|
||||
updateCounter: 1,
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -118,7 +116,7 @@ describe('The SyncConfig store', () => {
|
|||
_version: VERSION,
|
||||
flagStorage: {
|
||||
...defaultState.flagStorage,
|
||||
updateCounter: CURRENT_UPDATE_COUNTER,
|
||||
updateCounter: 1,
|
||||
},
|
||||
prefsStorage: {
|
||||
...defaultState.prefsStorage,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { createPinia, setActivePinia } from 'pinia'
|
|||
|
||||
import {
|
||||
_getRecentData,
|
||||
_mergePrefs,
|
||||
_mergeHighlights,
|
||||
_moveItemInArray,
|
||||
useUserHighlightStore,
|
||||
} from 'src/stores/user_highlight.js'
|
||||
|
|
@ -11,6 +11,15 @@ import {
|
|||
describe('The UserHighlight store', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
window.vuex = {
|
||||
state: {
|
||||
users: {
|
||||
currentUser: {
|
||||
fqn: 'foo@bar.tld',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
describe('mutations', () => {
|
||||
|
|
@ -20,23 +29,23 @@ describe('The UserHighlight store', () => {
|
|||
storage: {},
|
||||
}
|
||||
|
||||
it('should initialize storage if none present', () => {
|
||||
it('should initialize storage if none present', async () => {
|
||||
const store = useUserHighlightStore()
|
||||
store.initUserHighlight({ ...user })
|
||||
await store.initUserHighlight({ ...user })
|
||||
expect(store.cache._timestamp).to.be.a('number')
|
||||
expect(store.cache.highlight).to.eql({ _journal: [] })
|
||||
})
|
||||
|
||||
it('should initialize storage for new users if none present', () => {
|
||||
it('should initialize storage for new users if none present', async () => {
|
||||
const store = useUserHighlightStore()
|
||||
store.initUserHighlight({ ...user, created_at: new Date() })
|
||||
await store.initUserHighlight({ ...user, created_at: new Date() })
|
||||
expect(store.cache._timestamp).to.be.a('number')
|
||||
expect(store.cache.highlight).to.eql({ _journal: [] })
|
||||
})
|
||||
|
||||
it('should use remote version if local missing', () => {
|
||||
it('should use remote version if local missing', async () => {
|
||||
const store = useUserHighlightStore()
|
||||
store.initUserHighlight(store, user)
|
||||
await store.initUserHighlight(store, user)
|
||||
expect(store.cache._timestamp).to.be.a('number')
|
||||
})
|
||||
})
|
||||
|
|
@ -161,10 +170,10 @@ describe('The UserHighlight store', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('_mergePrefs', () => {
|
||||
describe('_mergeHighlights', () => {
|
||||
it('should prefer recent and apply journal to it', () => {
|
||||
expect(
|
||||
_mergePrefs(
|
||||
_mergeHighlights(
|
||||
// RECENT
|
||||
{
|
||||
highlight: {
|
||||
|
|
@ -227,7 +236,7 @@ describe('The UserHighlight store', () => {
|
|||
|
||||
it('should work with objects', () => {
|
||||
expect(
|
||||
_mergePrefs(
|
||||
_mergeHighlights(
|
||||
// RECENT
|
||||
{
|
||||
highlight: { 'a@test.xyz': { type: 'foo' } },
|
||||
|
|
@ -268,7 +277,7 @@ describe('The UserHighlight store', () => {
|
|||
|
||||
it('should work with unset', () => {
|
||||
expect(
|
||||
_mergePrefs(
|
||||
_mergeHighlights(
|
||||
// RECENT
|
||||
{
|
||||
highlight: { 'a@test.xyz': { type: 'foo' } },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue