Skip to content

Commit fde2cb0

Browse files
fixes tests
1 parent 0996b73 commit fde2cb0

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

tests/models/models.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ test('Merges VueObject', t => {
8787
]
8888
}
8989
}
90-
defaultObject.mergeVueObject(testVueObject);
91-
t.deepEqual(defaultObject.vue.head.meta, [{foo: true}, {bar: false}]);
90+
const mergedObject = Defaults.mergeObjects(defaultObject.options.vue, testVueObject);
91+
t.deepEqual(mergedObject.head.meta, [{foo: true}, {bar: false}]);
9292
})

tests/parser/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ import {
1212

1313
const compiler = require('vue-template-compiler');
1414

15+
var LRU = require('lru-cache');
16+
var cacheOptions = {
17+
max: 500,
18+
maxAge: 1000 * 60 * 60
19+
};
20+
var lruCache = LRU(cacheOptions);
21+
1522
let types = new Types();
1623
const component = __dirname + '/../../example/vueFiles/components/uuid.vue';
1724
const options = {
@@ -54,7 +61,7 @@ const parsedContentObject = {
5461
};
5562

5663
test('it should parse components', t => {
57-
return Parser.componentParser(component, defaultObject, types.COMPONENT)
64+
return Parser.componentParser(component, defaultObject, types.COMPONENT, lruCache)
5865
.then(function (layout) {
5966
const exampleLayout = {
6067
type: 'COMPONENT',
@@ -96,7 +103,7 @@ test('it should parse style', t => {
96103
});
97104

98105
test('it should parse scripts', t => {
99-
return Parser.scriptParser(parsedContentObject.script, defaultObject, types.SUBCOMPONENT)
106+
return Parser.scriptParser(parsedContentObject.script, defaultObject, types.SUBCOMPONENT, lruCache)
100107
.then(script => {
101108
t.is(typeof script, 'object');
102109
})

tests/utils/checkPathUtils.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ import Models from '../../src/models';
77

88
const rootPath = path.join(__dirname, '../../example/vueFiles/');
99
const defaults = new Models.Defaults();
10+
var LRU = require('lru-cache');
11+
var cacheOptions = {
12+
max: 500,
13+
maxAge: 1000 * 60 * 60
14+
};
15+
var lruCache = LRU(cacheOptions);
1016

1117
test('correctPath Path', t => {
1218
const filePath = path.join(rootPath, '../../example/vueFiles/components/uuid.vue');
1319
const correctPath = rootPath + 'components/uuid.vue';
1420

15-
return PathUtils.getCorrectPathForFile(filePath, 'view', defaults)
21+
return PathUtils.getCorrectPathForFile(filePath, 'view', defaults, lruCache)
1622
.then(returnedPath => {
1723
t.is(returnedPath.path, correctPath);
1824
})
@@ -25,7 +31,7 @@ test('shows error for fake test Path ', t => {
2531
const filePath = path.join(rootPath, 'componentDoesntExist.vue');
2632
const errMessage = `Could not find test file at ${rootPath}componentDoesntExist.vue`
2733

28-
return PathUtils.getCorrectPathForFile(filePath, 'test', defaults)
34+
return PathUtils.getCorrectPathForFile(filePath, 'test', defaults, lruCache)
2935
.catch(error => {
3036
console.log(error)
3137
t.is(error.message, errMessage);

0 commit comments

Comments
 (0)