Skip to content

Commit 04f1a26

Browse files
author
Vinayak Kulkarni
committed
🎉 Tests
1 parent 3bf9aad commit 04f1a26

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

karma.conf.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Karma configuration
2+
module.exports = function(config) {
3+
config.set({
4+
5+
// base path that will be used to resolve all patterns (eg. files, exclude)
6+
basePath: '',
7+
8+
// frameworks to use
9+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
10+
frameworks: ['jasmine', 'browserify'],
11+
12+
// list of files / patterns to load in the browser
13+
files: [
14+
'test/**/*.js'
15+
],
16+
17+
// list of files to exclude
18+
exclude: [],
19+
20+
// preprocess matching files before serving them to the browser
21+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
22+
preprocessors: {
23+
'test/**/*.spec.js': ['browserify']
24+
},
25+
26+
// test results reporter to use
27+
// possible values: 'dots', 'progress'
28+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
29+
reporters: ['spec'],
30+
31+
// web server port
32+
port: 9876,
33+
34+
// enable / disable colors in the output (reporters and logs)
35+
colors: true,
36+
37+
// level of logging
38+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
39+
logLevel: config.LOG_INFO,
40+
41+
// enable / disable watching file and executing tests whenever any file changes
42+
autoWatch: true,
43+
44+
// start these browsers
45+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
46+
browsers: ['PhantomJS'],
47+
48+
// Continuous Integration mode
49+
// if true, Karma captures browsers, runs the tests and exits
50+
singleRun: true,
51+
52+
// Browserify config
53+
browserify: {
54+
transform: [
55+
['babelify', { presets: ['es2015'] }],
56+
['aliasify', { aliases: { 'vue': 'vue/dist/vue.js' } }]
57+
],
58+
debug: true
59+
}
60+
})
61+
}

test/index.spec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const Vue = require('vue');
2+
const VueSort = require('../src/index');
3+
4+
function getComponent(Component, propsData) {
5+
const Ctor = Vue.extend(Component);
6+
return new Ctor({ propsData }).$mount();
7+
}
8+
9+
var exampleData = {
10+
sort: 1,
11+
sorttype: 'desc'
12+
};
13+
14+
describe('VueSortingTest', function() {
15+
it('emits correct event', function(done) {
16+
const vm = getComponent(VueSort, {
17+
data: exampleData
18+
});
19+
20+
vm.$on('sort-data', function (sort, direction) {
21+
expect(sort).toBe(1);
22+
expect(direction).toBe('desc');
23+
done();
24+
});
25+
26+
vm.sortData(1, 'desc');
27+
});
28+
});

0 commit comments

Comments
 (0)