Skip to content

Commit e746732

Browse files
committed
Add test app
1 parent 3e6260b commit e746732

File tree

5 files changed

+118
-1
lines changed

5 files changed

+118
-1
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Hackable charting lib for traders",
55
"main": "./dist/trading-vue.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1",
7+
"test": "webpack-dev-server --config webpack/test.config.js --mode development --progress --hot",
88
"dev": "webpack-dev-server --config webpack/dev.config.js --mode development --progress --hot",
99
"build": "webpack --config webpack/build.config.js --mode production --progress"
1010
},

Diff for: test/Test.vue

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<trading-vue :data="chart" :width="this.width" :height="this.height"
3+
:color-back="colors.colorBack"
4+
:color-grid="colors.colorGrid"
5+
:color-text="colors.colorText">
6+
</trading-vue>
7+
</template>
8+
9+
<script>
10+
import TradingVue from '../src/TradingVue.vue'
11+
import Data from '../data/data.json'
12+
import Utils from '../src/stuff/utils.js'
13+
14+
export default {
15+
name: 'app',
16+
components: {
17+
TradingVue
18+
},
19+
methods: {
20+
onResize(event) {
21+
this.width = window.innerWidth
22+
this.height = window.innerHeight
23+
}
24+
},
25+
mounted() {
26+
window.addEventListener('resize', this.onResize)
27+
setTimeout(() => {
28+
// Async data setup
29+
this.$set(this, 'chart', Data)
30+
}, 0)
31+
},
32+
beforeDestroy() {
33+
window.removeEventListener('resize', this.onResize)
34+
},
35+
data() {
36+
return {
37+
chart: {}, // Data will be here,
38+
width: window.innerWidth,
39+
height: window.innerHeight,
40+
colors: {
41+
colorBack: '#fff',
42+
colorGrid: '#eee',
43+
colorText: '#333',
44+
}
45+
};
46+
}
47+
};
48+
</script>
49+
50+
<style>
51+
html,
52+
body {
53+
background-color: #000;
54+
margin: 0;
55+
padding: 0;
56+
overflow: hidden;
57+
}
58+
</style>

Diff for: test/index.html

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta http-equiv="x-ua-compatible" content="ie=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<title>TradingVue.js Tests</title>
9+
<style>
10+
</style>
11+
</head>
12+
13+
<body>
14+
<!-- Our vue app will be mounted on this DOM element -->
15+
<div id="app"></div>
16+
<!-- Bundle will be injected below -->
17+
</body>
18+
19+
</html>

Diff for: test/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Vue from 'vue';
2+
3+
import App from './Test.vue';
4+
5+
new Vue({
6+
el: '#app',
7+
render: h => h(App)
8+
});

Diff for: webpack/test.config.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const VueLoaderPlugin = require('vue-loader/lib/plugin')
2+
const HtmlWebpackPlugin = require('html-webpack-plugin')
3+
4+
module.exports = {
5+
entry: './test/index.js',
6+
module: {
7+
rules: [{
8+
test: /\.vue$/,
9+
exclude: /node_modules/,
10+
loader: 'vue-loader'
11+
},
12+
{
13+
test: /\.js$/,
14+
exclude: /node_modules/,
15+
loader: 'babel-loader'
16+
},
17+
{
18+
test: /\.css$/,
19+
use: [
20+
'vue-style-loader',
21+
'css-loader'
22+
]
23+
},
24+
]
25+
},
26+
plugins: [
27+
new VueLoaderPlugin(),
28+
new HtmlWebpackPlugin({
29+
template: './test/index.html'
30+
})
31+
],
32+
}

0 commit comments

Comments
 (0)