Skip to content

Commit 281c48d

Browse files
committed
fixed tests. Removed duplicate files in the example project. Fixed the example project with the new folders
1 parent 5d988cf commit 281c48d

File tree

8 files changed

+12
-48
lines changed

8 files changed

+12
-48
lines changed

example/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var exampleMixin = {
1515
};
1616

1717
const options = {
18-
rootPath: path.join(__dirname, '/vueFiles'),
18+
rootPath: path.join(__dirname, ''),
1919
vue: {
2020
head: {
2121
meta: [{
@@ -66,7 +66,7 @@ app.get('/', (req, res) => {
6666
]
6767
}
6868
}
69-
res.renderVue('main/main.vue', data, vueOptions)
69+
res.renderVue('main.vue', data, vueOptions)
7070
});
7171

7272
app.listen(3000);

example/components/uuid.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</template>
77

88
<script>
9-
import inner from '../components/inner.vue';
9+
import inner from './components/inner.vue';
1010
export default {
1111
props: ['uuid'],
1212
data: function () {
File renamed without changes.

example/vueFiles/main/main.vue

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/parser/component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const fs = require('fs');
44
const camelCase = require('camel-case');
55
const compiler = require('vue-template-compiler');
6+
const CleanCSS = require('clean-css');
67
const styleParser = require('./style');
78
const htmlParser = require('./html');
89
const scriptParser = require('./script');
@@ -69,7 +70,7 @@ function parseContent(content: string, templatePath: string, defaults: Object, t
6970
if (resultsArray[2]) {
7071
style = resultsArray[2];
7172
} else {
72-
style = resultsArray[1].styles ? resultsArray[1].styles : '';
73+
style = new CleanCSS({}).minify(resultsArray[1].styles ? resultsArray[1].styles : '').styles;
7374
}
7475

7576
script.template = template;

tests/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Models = require('../src/models');
55
const path = require('path');
66

77
const options = {
8-
rootPath: path.join(__dirname, '../example/vueFiles')
8+
rootPath: path.join(__dirname, '../example')
99
};
1010

1111
const data = {
@@ -20,8 +20,8 @@ const vueOptions = {
2020
}
2121
}
2222

23-
const exampleHead = `<head>\n<title>Page Title</title>\n</head>`;
24-
const exampleScript = `<script>(function(){"use strict";var u=function(){return new Vue({mixins:[{methods:{hello:function(){console.log('Hello')}}}],data:function(){return{"title":"Express Vue","message":"Hello world","uuid":"farts"}},methods:{test:function(){console.error('test')}},components:{uuid:{props:["uuid"],data:function(){return{}},template:"<div><h2>Uuid: {{uuid ? uuid : 'no uuid'}}</h2></div>"},uuid2:{props:["uuid2"],data:function(){return{}},template:"<div><h3>Uuid2: {{uuid2 ? uuid2 : 'no uuid'}}</h3></div>"}},template:"<div><h1>{{title}}</h1><p>Welcome to the {{title}} demo. Click a link:</p><input v-model=\\"message\\" placeholder=\\"edit me\\"><p>{{message}}</p><uuid :uuid=\\"uuid\\"></uuid><uuid2 :uuid2=\\"uuid2\\"></uuid2><button type=\\"button\\" name=\\"button\\" v-on:click=\\"this.hello\\">Test mixin</button> <button type=\\"button\\" name=\\"button\\" v-on:click=\\"this.test\\">Test method</button></div>"})};typeof module!=='undefined'&&module.exports?(module.exports=u):(this.app=u())}).call(this),app.$mount('#app')</script>`
23+
const exampleHead = `<head>\n<title>Page Title</title>\n<style>.test{color:#00f}.red{color:#9acd32}</style></head>`;
24+
const exampleScript = `<script>(function(){"use strict";var u=function(){return new Vue({mixins:[{methods:{hello:function(){console.log(\'Hello\')}}}],data:function(){return{"title":"Express Vue","message":"Hello world","uuid":"farts"}},methods:{test:function(){console.error(\'test\')}},components:{uuid:{props:["uuid"],data:function(){return{}},components:{inner:{data:function(){return{}},template:"<div><p>Inner Text</p></div>"}},styles:"",template:"<div><inner></inner><h2 class=\\"test\\">Uuid: {{uuid ? uuid : \'no uuid\'}}</h2></div>"},uuid2:{props:["uuid2"],data:function(){return{}},template:"<div><h3 class=\\"red\\">Uuid2: {{uuid2 ? uuid2 : \'no uuid\'}}</h3></div>"}},styles:".test{color:#00f}.red{color:#9acd32}",template:"<div><h1>{{title}}</h1><p>Welcome to the {{title}} demo. Click a link:</p><input v-model=\\"message\\" placeholder=\\"edit me\\"><p>{{message}}</p><uuid :uuid=\\"uuid\\"></uuid><uuid2 :uuid2=\\"uuid2\\"></uuid2><button type=\\"button\\" name=\\"button\\" v-on:click=\\"this.hello\\">Test mixin</button> <button type=\\"button\\" name=\\"button\\" v-on:click=\\"this.test\\">Test method</button></div>"})};typeof module!==\'undefined\'&&module.exports?(module.exports=u):(this.app=u())}).call(this),app.$mount(\'#app\')</script>`;
2525

2626
test('renders App object', t => {
2727
const renderer = new ExpressVueRenderer(options);

tests/parser/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ var cacheOptions = {
2020
var lruCache = LRU(cacheOptions);
2121

2222
let types = new Types();
23-
const component = __dirname + '/../../example/vueFiles/components/uuid.vue';
23+
const component = __dirname + '/../../example/components/uuid.vue';
2424
const options = {
25-
rootPath: path.join(__dirname, 'tests'),
25+
rootPath: path.join(__dirname, '../../example'),
2626
component: 'uuid.vue'
2727
};
2828

tests/utils/checkPathUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from '../../src/utils';
66
import Models from '../../src/models';
77

8-
const rootPath = path.join(__dirname, '../../example/vueFiles/');
8+
const rootPath = path.join(__dirname, '../../example/');
99
const defaults = new Models.Defaults();
1010
var LRU = require('lru-cache');
1111
var cacheOptions = {
@@ -15,7 +15,7 @@ var cacheOptions = {
1515
var lruCache = LRU(cacheOptions);
1616

1717
test('correctPath Path', t => {
18-
const filePath = path.join(rootPath, '../../example/vueFiles/components/uuid.vue');
18+
const filePath = path.join(rootPath, '../example/components/uuid.vue');
1919
const correctPath = rootPath + 'components/uuid.vue';
2020

2121
return PathUtils.getCorrectPathForFile(filePath, 'view', defaults, lruCache)

0 commit comments

Comments
 (0)