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

Fixed a couple of issues uncovered by the store test

parent ee88756d
Pipeline #1868 passed with stage
in 9 minutes
...@@ -4,15 +4,18 @@ module.exports = config => { ...@@ -4,15 +4,18 @@ module.exports = config => {
config.set({ config.set({
frameworks: ['jasmine'], frameworks: ['jasmine'],
files: [ files: [
{pattern: 'test/**/*test.js'} {pattern: 'test/**/*-test.js'}
], ],
browsers: ['PhantomJS'], browsers: ['PhantomJS'],
preprocessors: { preprocessors: {
'test/**/*test.js': ['webpack', 'sourcemap'] 'test/**/*-test.js': ['webpack']
}, },
webpack: webpackConfig, webpack: webpackConfig,
webpackMiddleware: { webpackMiddleware: {
stats: 'errors-only' noInfo: false,
stats: {
color: true
}
}, },
singleRun: true, singleRun: true,
colors: true colors: true
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"author": "Sascha Herzinger", "author": "Sascha Herzinger",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "./node_modules/webpack/bin/webpack.js --config webpack.config.js", "build": "./node_modules/webpack/bin/webpack.js --config webpack.config.js --env build",
"test": "./node_modules/karma/bin/karma start karma.config.js" "test": "./node_modules/karma/bin/karma start karma.config.js"
}, },
"dependencies": { "dependencies": {
...@@ -17,9 +17,10 @@ ...@@ -17,9 +17,10 @@
"babel-core": "^6.24.0", "babel-core": "^6.24.0",
"babel-preset-latest": "^6.24.0", "babel-preset-latest": "^6.24.0",
"babel-polyfill": "^6.23.0", "babel-polyfill": "^6.23.0",
"babel-plugin-add-module-exports": "^0.2.1",
"webpack": "^2.2.1", "webpack": "^2.2.1",
"babel-loader": "^6.4.0", "babel-loader": "^7.0.0-beta.1",
"vue-loader": "^11.1.4", "vue-loader": "^11.1.4",
"css-loader": "^0.27.3", "css-loader": "^0.27.3",
...@@ -29,10 +30,10 @@ ...@@ -29,10 +30,10 @@
"eslint-plugin-promise": "^3.5.0", "eslint-plugin-promise": "^3.5.0",
"karma": "^1.5.0", "karma": "^1.5.0",
"jasmine-core": "^2.5.2",
"karma-sourcemap-loader": "^0.3.7", "karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.3", "karma-webpack": "^2.0.3",
"karma-jasmine": "^1.1.0", "karma-phantomjs-launcher": "^1.0.4",
"karma-phantomjs-launcher": "^1.0.4" "jasmine-core": "^2.5.2",
"karma-jasmine": "^1.1.0"
} }
} }
\ No newline at end of file
import 'babel-polyfill' import store from './store/store'
import { store } from './store' import RequestManager from './services/request-manager'
import { RequestManager } from './services/request-manager' import ChartManager from './services/chart-manager'
import { ChartManager } from './services/chart-manager'
class FractalJS { class FractalJS {
constructor (handler, thisBaseURL, fractalisBaseURL, getAuth) { constructor (handler, thisBaseURL, fractalisBaseURL, getAuth) {
......
import Vue from 'vue' import Vue from 'vue'
import CorrelationAnalysis from '../components/charts/correlation-analysis.vue' import CorrelationAnalysis from '../components/charts/correlation-analysis.vue'
class ChartManager { export default class {
constructor () { constructor () {
this.AVAILABLE_CHARTS = { this.AVAILABLE_CHARTS = {
'correlation-analysis': CorrelationAnalysis 'correlation-analysis': CorrelationAnalysis
...@@ -18,5 +18,3 @@ class ChartManager { ...@@ -18,5 +18,3 @@ class ChartManager {
vm.$mount(elementId) vm.$mount(elementId)
} }
} }
export { ChartManager }
\ No newline at end of file
import axios from 'axios' import axios from 'axios'
class RequestManager { export default class {
constructor ({handler, thisBaseURL, fractalisBaseURL, getAuth} = {}) { constructor ({handler, thisBaseURL, fractalisBaseURL, getAuth} = {}) {
this._handler = handler this._handler = handler
this._thisBaseURL = thisBaseURL this._thisBaseURL = thisBaseURL
...@@ -77,5 +77,3 @@ class RequestManager { ...@@ -77,5 +77,3 @@ class RequestManager {
}) })
} }
} }
export { RequestManager }
export const subsets = state => state.subsets
import * as types from './mutation-types' import * as types from './mutation-types'
export default { export default {
[types.SET_REQUEST_MANAGER] (state, { manager }) { [types.SET_REQUEST_MANAGER] (state, manager) {
state.requestManager = manager state.requestManager = manager
}, },
[types.SET_SUBSETS] (state, { subsets }) { [types.SET_SUBSETS] (state, subsets) {
state.subsets = subsets state.subsets = subsets
} }
} }
import 'babel-polyfill' // included here for testing
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import * as getters from './getters' import * as getters from './getters'
...@@ -12,11 +11,9 @@ const state = { ...@@ -12,11 +11,9 @@ const state = {
subsets: [] subsets: []
} }
const store = new Vuex.Store({ export default new Vuex.Store({
state, state,
getters, getters,
actions, actions,
mutations mutations
}) })
export { store }
import { store } from '../src/store' import 'babel-polyfill'
import store from '../src/store/store'
describe('store', () => { describe('store', () => {
it('should have working subsets setter', () => { it('should have working setSubsets action', () => {
const subsets = [[1, 2, 3], [4, 5, 6], [6, 7, 8]] const subsets = [[1, 2, 3], [4, 5, 6], [6, 7, 8]]
store.dispatch('setSubsets', subsets) store.dispatch('setSubsets', subsets)
expect(store.state.subsets).toEqual(subsets) expect(store.state.subsets).toEqual(subsets)
......
const webpack = require('webpack')
const path = require('path') const path = require('path')
const env = require('yargs').argv.env;
let plugins = []
let filename = ''
const library = 'fractal'
if (env === 'build') {
plugins.push(new webpack.optimize.UglifyJsPlugin({minimize: true}))
filename = library + '.min.js'
} else {
filename = library + '.js'
}
module.exports = { module.exports = {
entry: path.resolve(__dirname, 'src/main.js'), entry: ['babel-polyfill', path.resolve(__dirname, 'src/main.js')],
devtool: 'source-map', devtool: '#inline-source-map',
plugins: plugins,
output: { output: {
path: path.resolve(__dirname, 'lib'), path: path.resolve(__dirname, 'lib'),
library: 'fractal', library: library,
libraryTarget: 'var', libraryTarget: 'var',
filename: 'fractal.js' filename: filename
}, },
module: { module: {
rules: [ rules: [
{ {
test: /\.vue$/, test: /\.vue$/,
loader: 'vue-loader', loader: 'vue-loader',
exclude: /node_modules/ exclude: /node_modules/,
options: {
// compile the <script></script> part of vue components with babel
loaders: {
js: 'babel-loader'
}
}
}, },
{ {
test: /\.js$/, test: /\.js$/,
loader: 'babel-loader', loader: 'babel-loader',
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'test')
],
exclude: /node_modules/ exclude: /node_modules/
} }
] ]
......
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