first commit

This commit is contained in:
2025-01-06 20:47:25 +01:00
commit 3bdbd78c2f
25591 changed files with 3586440 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
/* eslint-disable */
import Vue from 'vue';
Vue.config.productionTip = false;
// require all test files (files that ends with .spec.js)
var testsContext = require.context('./specs', true, /\.spec$/);
testsContext.keys().forEach(testsContext);
const srcContext = require.context('../../pages/', true, /^\.\/(?!main(\.js)?$)/);
srcContext.keys().forEach(srcContext);

View File

@@ -0,0 +1,86 @@
/* eslint-disable */
// Karma configuration
// Generated on Fri May 19 2017 10:32:08 GMT+0200 (CEST)
var webpackConfig = require('../../../../webpack.config.js');
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '.',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'sinon-chai', 'chai-jquery', 'chai', 'jquery-1.8.3'],
// list of files / patterns to load in the browser
files: [
'./index.js',
],
// list of files to exclude
exclude: [
'node_modules',
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'./index.js': ['webpack', 'babel', 'coverage'],
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true,
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['spec'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,
coverageReporter: {
dir: './coverage',
reporters: [
{type: 'html', dir:'./coverage'},
]
}
})
}

View File

@@ -0,0 +1,118 @@
/* eslint-disable */
import Vue from 'vue';
import Vuex from 'vuex';
import VueRouter from 'vue-router'
import Translation from 'app/pages/stock/mixins/translate';
import App from 'app/pages/stock/components/app.vue';
Vue.use(Vuex);
Vue.use(VueRouter);
Vue.mixin(Translation);
let router = new VueRouter({path: 'overview'})
const PAGE_COUNT_MOCK = 2;
const PAGINATION_INDEX_MOCK = 1;
const mockedStore = {
state: {
isReady: true,
translations: {},
movementsTypes: [],
categories: [],
suppliers: [],
totalPages: PAGE_COUNT_MOCK,
pageIndex: PAGINATION_INDEX_MOCK,
},
getters: {
suppliers: () => {
return [];
},
categories: () => {
return [];
},
},
actions: {
getSuppliers() {
},
getCategories() {
},
isLoading() {
},
getMovements() {
}
}
}
window.data = {
catalogUrl: ''
}
$.fn.datetimepicker = function() {
return {
on: function() {
}
}
};
describe('app.vue', () => {
const Constructor = Vue.extend(App);
var vm = new Constructor({
store: new Vuex.Store(mockedStore),
router
}).$mount();
it('should exist', () => {
expect(vm.$el).to.exist;
});
it('should have stock app class', function () {
$(vm.$el).should.have.class('stock-app');
});
it('should not display app when translations are not loaded', function () {
mockedStore.state.isReady = false;
vm = new Constructor({
store: new Vuex.Store(mockedStore),
router
}).$mount();
$(vm.$el).should.not.have.class('stock-app');
});
it('should have a data property called filters', function () {
expect(App.data().filters).to.exist;
});
it('should have 3 children components', function () {
expect(App.components.StockHeader).to.exist;
expect(App.components.Search).to.exist;
expect(App.components.PSPagination).to.exist;
});
it('should have a computed property isReady', function () {
expect(vm.isReady).to.be.false;
});
it('should have a computed property pagesCount', function () {
expect(vm.pagesCount).to.equal(PAGE_COUNT_MOCK);
});
it('should have a computed property currentPagination', function () {
expect(vm.currentPagination).to.equal(PAGINATION_INDEX_MOCK);
});
it('should have a method fetch which call actions', function () {
var spy = sinon.spy(vm.$store, 'dispatch');
vm.fetch();
assert(spy.calledWith('isLoading'));
assert(spy.calledWith('getMovements'));
spy.restore();
});
});