Skip to content

Commit

Permalink
Add test for general collection component
Browse files Browse the repository at this point in the history
  • Loading branch information
raimund-schluessler committed Oct 28, 2019
1 parent af8aeb1 commit 2c2a3c8
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 1 deletion.
89 changes: 89 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"eslint-plugin-vue": "^5.2.3",
"file-loader": "^4.2.0",
"jest": "^24.9.0",
"jest-environment-jsdom-fourteen": "^0.1.0",
"jest-serializer-vue": "^2.0.2",
"jsdom": "^15.1.1",
"jsdom-global": "^3.0.2",
Expand Down Expand Up @@ -105,13 +106,17 @@
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/src/$1"
},
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
},
"snapshotSerializers": [
"<rootDir>/node_modules/jest-serializer-vue"
],
"setupFilesAfterEnv": [
"./tests/javascript/unit/setup.js"
],
"coverageDirectory": "./coverage/",
"collectCoverage": true,
"collectCoverageFrom": [
Expand Down
4 changes: 4 additions & 0 deletions tests/javascript/unit/OC.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ export class OC {
return ''
}

linkToRemote(app) {
return ''
}

}
48 changes: 48 additions & 0 deletions tests/javascript/unit/components/TheCollections/General.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { mount, createLocalVue } from '@vue/test-utils'
import General from '../../../../../src/components/TheCollections/General'
import store from '../../../../../src/store/store'
import router from '../../../../../src/components/TheRouter'

import { mapDavCollectionToCalendar } from '../../../../../src/store/calendars'

import VTooltip from 'v-tooltip'

const localVue = createLocalVue()
localVue.use(VTooltip)

describe('General.vue', () => {
'use strict'

const calendarsData = [
{
url: 'calendar-1/tmp',
displayname: 'Calendar 1',
color: '#123456',
isWriteable: () => { return true },
shares: [],
components: ['VTODO'],
},
{
url: 'calendar-2/tmp',
displayname: 'Calendar 2',
color: '#123456',
isWriteable: () => { return true },
shares: [],
components: ['VTODO', 'VEVENT'],
},
]

calendarsData.forEach(calendarData => {
const calendar = mapDavCollectionToCalendar(calendarData)
store.commit('addCalendar', calendar)
})

it('Checks that we get the correct number of calendars', () => {
const wrapper = mount(General, { localVue, store, router })
expect(wrapper.vm.calendars.length).toBe(2)
})

// it('Checks if correct tasks are found for current collection', () => {
// const wrapper = mount(General, { localVue, store, router })
// })
})
18 changes: 17 additions & 1 deletion tests/javascript/unit/setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
require('jsdom-global')()
import VueTestUtils from '@vue/test-utils'
import { OC } from './OC.js'

global.OC = new OC()

// Mock nextcloud translate functions
VueTestUtils.config.mocks.$t = function(app, string) {
return string
}
VueTestUtils.config.mocks.t = VueTestUtils.config.mocks.$t
global.t = VueTestUtils.config.mocks.$t

VueTestUtils.config.mocks.$n = function(app, singular, plural, count) {
return singular
}
VueTestUtils.config.mocks.n = VueTestUtils.config.mocks.$n
global.n = VueTestUtils.config.mocks.$n

0 comments on commit 2c2a3c8

Please sign in to comment.