Commit 5d7c277b authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

Some additional tests

parent 2a4d40ea
......@@ -19,47 +19,43 @@
},
"main": "lib/fractal.min.js",
"dependencies": {
"vue": "^2.3.3",
"vue-template-compiler": "^2.3.3",
"vuex": "^2.3.1",
"axios": "^0.16.1",
"d3": "^4.7.4",
"d3-tip": "^0.7.1",
"gsap": "^1.19.1",
"deep-freeze-strict": "^1.1.1",
"gsap": "^1.20.0",
"jquery": "^3.2.1",
"deep-freeze-strict": "^1.1.1"
"vue": "^2.3.3",
"vue-template-compiler": "^2.3.3",
"vuex": "^2.3.1"
},
"devDependencies": {
"babel-core": "7.0.0-alpha.3",
"babel-preset-latest": "7.0.0-alpha.3",
"babel-loader": "^7.1.1",
"babel-plugin-transform-runtime": "7.0.0-alpha.9",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5",
"yargs": "^7.0.2",
"babel-loader": "^7.0.0-beta.1",
"vue-loader": "^12.2.1",
"babel-preset-latest": "7.0.0-alpha.3",
"css-loader": "^0.27.3",
"style-loader": "^0.17.0",
"sass-loader": "^6.0.3",
"node-sass": "^4.5.2",
"url-loader": "^0.5.8",
"file-loader": "^0.11.1",
"eslint": "^3.17.1",
"eslint-config-standard": "^7.0.1",
"eslint-plugin-standard": "^2.1.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-html": "^2.0.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^2.1.1",
"file-loader": "^0.11.1",
"jasmine-core": "^2.6.4",
"jsdoc": "^3.4.3",
"karma": "^1.5.0",
"karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.3",
"karma-phantomjs-launcher": "^1.0.4",
"karma-chrome-launcher": "^2.0.0",
"jasmine-core": "^2.5.2",
"karma-jasmine": "^1.1.0",
"jsdoc": "^3.4.3"
"node-sass": "^4.5.2",
"sass-loader": "^6.0.6",
"style-loader": "^0.17.0",
"url-loader": "^0.5.8",
"vue-loader": "^12.2.1",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.5.0",
"yargs": "^7.0.2"
}
}
\ No newline at end of file
}
......@@ -516,7 +516,6 @@
border-radius: 8px
margin: 10px
.fjs-vis-container
flex: 1
display: flex
......
......@@ -47,5 +47,17 @@ class FractalJS {
* @returns {FractalJS}: An instance of FractalJS.
*/
export function init ({handler, thisBaseURL, fractalisBaseURL, getAuth}) {
if (!handler) {
throw new Error(`handler property must not be ${handler}`)
}
if (!thisBaseURL) {
throw new Error(`handler property must not be ${thisBaseURL}`)
}
if (!fractalisBaseURL) {
throw new Error(`handler property must not be ${fractalisBaseURL}`)
}
if (!getAuth) {
throw new Error(`handler property must not be ${getAuth}`)
}
return new FractalJS(handler, thisBaseURL, fractalisBaseURL, getAuth)
}
......@@ -20,7 +20,9 @@ export default {
* @param subsets An array of arrays of ids defining the subsets.
*/
setSubsets: (context, subsets) => {
if (subsets instanceof Array && ((subsets.length > 0 && subsets[0] instanceof Array) || !subsets.length)) {
if (subsets instanceof Array &&
((subsets.length > 0 && subsets[0] instanceof Array) || !subsets.length) &&
subsets.every(d => Array.isArray(d))) {
context.commit(types.SET_SUBSETS, subsets)
} else {
throw new Error('The dispatched value must be an Array containing Arrays (unless empty).')
......
......@@ -29,20 +29,24 @@
.then(() => {
fjs.loadData([
{
data_type: 'Integer',
data_set: 'ppmi.clinical_visit',
projection: 'VITALHTCM',
get label () {
return `${this.projection} (${this.data_set})`
}
dictionary: {
name: 'VITALHTCM',
projection: 'VITALHTCM',
label: 'Height',
fieldType: 'Integer',
isArray: false
},
data_set: 'ppmi.clinical_visit'
},
{
data_type: 'Double',
data_set: 'ppmi.clinical_visit',
projection: 'VITALWGTKG',
get label () {
return `${this.projection} (${this.data_set})`
}
dictionary: {
name: 'VITALWGTKG',
projection: 'VITALWGTKG',
label: 'Weight',
fieldType: 'Double',
isArray: false
},
data_set: 'ppmi.clinical_visit'
}
])
})
......
import { init } from '../src/main'
describe('initializer', () => {
it('throws if given invalid parameters', () => {
let f = () => init({handler: '', thisBaseURL: 'foo', fractalisBaseURL: 'foo', getAuth: () => {}})
expect(f).toThrow()
f = () => init({handler: 'foo', thisBaseURL: '', fractalisBaseURL: 'foo', getAuth: () => {}})
expect(f).toThrow()
f = () => init({handler: 'foo', thisBaseURL: 'foo', fractalisBaseURL: '', getAuth: () => {}})
expect(f).toThrow()
f = () => init({thisBaseURL: 'foo', fractalisBaseURL: 'foo', getAuth: () => {}})
expect(f).toThrow()
f = () => init({handler: 'foo', fractalisBaseURL: 'foo', getAuth: () => {}})
expect(f).toThrow()
f = () => init({handler: 'foo', thisBaseURL: 'foo', getAuth: () => {}})
expect(f).toThrow()
f = () => init({handler: 'foo', thisBaseURL: 'foo', fractalisBaseURL: 'foo'})
expect(f).toThrow()
})
it('returns FractalJS instance if given valid parameters', () => {
const fjs = init({handler: 'ada', thisBaseURL: 'foo', fractalisBaseURL: 'foo', getAuth: () => {}})
expect(fjs.constructor.name).toBe('FractalJS')
})
})
......@@ -2,27 +2,60 @@ import store from '../src/store/store'
import RequestManager from '../src/services/request-manager'
describe('store', () => {
it('should have working setSubsets action', () => {
const subsets = [[1, 2, 3], [4, 5, 6], [6, 7, 8]]
store.dispatch('setSubsets', subsets)
expect(store.getters.subsets).toEqual(subsets)
describe('setSubsets action', () => {
it('should correctly set store values', () => {
const subsets = [[1, 2, 3], [4, 5, 6], [6, 7, 8]]
store.dispatch('setSubsets', subsets)
expect(store.getters.subsets).toEqual(subsets)
})
it('should work with empty array', () => {
const subsets = []
store.dispatch('setSubsets', subsets)
expect(store.getters.subsets).toEqual(subsets)
})
it('should fail if invalid subsets given', () => {
const f = () => store.dispatch('setSubsets', ['a', [1, 2, 3]])
const g = () => store.dispatch('setSubsets', {a: 1})
expect(f).toThrow()
expect(g).toThrow()
})
})
it('should have working setRequestManager action', () => {
const requestManager = new RequestManager({
handler: 'ada',
thisBaseURL: 'https://localhost:1234',
fractalisBaseURL: 'https://localhost:4321',
getAuth: () => ({token: '1234567890'})
describe('setRequestManager action', () => {
it('should correctly set store values', () => {
const requestManager = new RequestManager({
handler: 'ada',
thisBaseURL: 'https://localhost:1234',
fractalisBaseURL: 'https://localhost:4321',
getAuth: () => ({token: '1234567890'})
})
store.dispatch('setRequestManager', requestManager)
expect(store.getters.requestManager).not.toBeNull()
})
it('should fail if set value is no request manager', () => {
const requestManager = {}
const f = () => store.dispatch('setRequestManager', requestManager)
expect(f).toThrow()
})
store.dispatch('setRequestManager', requestManager)
expect(store.getters.requestManager).not.toBeNull()
})
it('should have working setTask', () => {
expect(Object.keys(store.getters.tasks).length).toBe(0)
const task = {taskID: 'A', taskName: 'foo', taskState: 'PENDING'}
store.dispatch('setTask', task)
expect(store.getters.tasks['A']).toBeDefined()
describe('task actions', () => {
it('should have working setTask action', () => {
const task = {taskID: 'A', taskName: 'foo', taskState: 'PENDING'}
store.dispatch('setTask', task)
expect(store.getters.tasks['A']).toBeDefined()
expect(store.getters.tasks['A'].taskName).toEqual(task.taskName)
expect(store.getters.tasks['A'].taskState).toEqual(task.taskState)
})
it('should have working unsetTask action', () => {
const task = {taskID: 'A', taskName: 'foo', taskState: 'PENDING'}
store.dispatch('setTask', task)
store.dispatch('unsetTask', {taskID: 'A'})
expect(store.getters.tasks['A']).not.toBeDefined()
})
})
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment