Commit ee88756d authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

Setting up first store test and introducing naming convention for files

parent 30395b9e
Pipeline #1832 failed with stage
in 23 seconds
......@@ -4,11 +4,11 @@ module.exports = config => {
config.set({
frameworks: ['jasmine'],
files: [
{pattern: 'test/**/*_test.js'}
{pattern: 'test/**/*test.js'}
],
browsers: ['PhantomJS'],
preprocessors: {
'test/**/*_test.js': ['webpack', 'sourcemap']
'test/**/*test.js': ['webpack', 'sourcemap']
},
webpack: webpackConfig,
webpackMiddleware: {
......
This diff is collapsed.
import 'babel-polyfill'
import { store } from './store'
import { RequestManager } from './services/requestManager'
import { ChartManager } from './services/chartManager'
import { RequestManager } from './services/request-manager'
import { ChartManager } from './services/chart-manager'
class FractalJS {
constructor (handler, thisBaseURL, fractalisBaseURL, getAuth) {
......@@ -11,15 +11,17 @@ class FractalJS {
this._chartManager = new ChartManager()
}
static loadData (descriptors) {
// noinspection JSMethodCanBeStatic
loadData (descriptors) {
store.requestManager.createData(descriptors)
}
static setChart (name, elementId) {
setChart (name, elementId) {
this._chartManager.setChart({name, elementId})
}
static setSubsets (...subsets) {
// noinspection JSMethodCanBeStatic
setSubsets (...subsets) {
store.dispatch('setSubsets', subsets)
}
}
......
import Vue from 'vue'
import CorrelationAnalysis from '../components/charts/CorrelationAnalysis.vue'
import CorrelationAnalysis from '../components/charts/correlation-analysis.vue'
class ChartManager {
constructor () {
......@@ -9,7 +9,7 @@ class ChartManager {
}
setChart ({name, elementId} = {}) {
if (this.AVAILABLE_CHARTS.indexOf(name) === -1) {
if (Object.keys(this.AVAILABLE_CHARTS).indexOf(name) === -1) {
throw Error(`Chart '${name} is not available.
Must be one of: ${this.AVAILABLE_CHARTS}`)
}
......
/**
* Created by sascha on 16/03/2017.
*/
export const subsets = state => state.subsets
import 'babel-polyfill' // included here for testing
import Vue from 'vue'
import Vuex from 'vuex'
import * as getters from './getters'
......@@ -7,7 +8,8 @@ import mutations from './mutations'
Vue.use(Vuex)
const state = {
requestManager: null
requestManager: null,
subsets: []
}
const store = new Vuex.Store({
......
/**
* Created by sascha on 21/03/2017.
*/
import ReqestHandler from '../src/services/requestManager'
describe('RequestHandler', () => {
it('throws if invalid constructor arguments 1', () => {
const params = {
handler: 'foo',
thisBaseURL: 'http://localhost:5000',
thisAuth: {token: '1234567890'},
fractalisBaseURL: 'http://fractalis.uni.lu'
}
expect(() => new ReqestHandler(params)).toThrowError()
})
})
\ No newline at end of file
import { store } from '../src/store'
describe('store', () => {
it('should have working subsets setter', () => {
const subsets = [[1, 2, 3], [4, 5, 6], [6, 7, 8]]
store.dispatch('setSubsets', subsets)
expect(store.state.subsets).toEqual(subsets)
})
})
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