Skip to content

Commit

Permalink
добавлен babel
Browse files Browse the repository at this point in the history
для продакшена
  • Loading branch information
Geksanit committed Nov 24, 2017
1 parent 90beca9 commit 5377cac
Show file tree
Hide file tree
Showing 17 changed files with 1,106 additions and 1,224 deletions.
628 changes: 358 additions & 270 deletions build/index.js

Large diffs are not rendered by default.

26 changes: 12 additions & 14 deletions frontend/controller/controller.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

import Controller from './Controller'
import '../components/standart-button/standart-button'
import Controller from './Controller';

describe('контроллер', function () {
let controller;
console.log('start controller test');
describe('вставка html кода', function () {
const div = document.createElement('div');
div.insertAdjacentHTML('beforeEnd', '<div class="game"> <table id="board"></table> <div id="controls"><button class="standart-button standart-button_ standart-button_small standart-button_-small" onclick="buttonClick(event)">start</button><button class="standart-button standart-button_ standart-button_small standart-button_-small" onclick="buttonClick(event)">pause</button><button class="standart-button standart-button_ standart-button_small standart-button_-small" onclick="buttonClick(event)">clear</button> <div class="container"> <div class="label">speed</div> <div class="slider"> <div class="slider__view">1</div><input class="slider" oninput="sliderInput(event)" type="range" min="1" max="10" value="1"> </div> </div> <div class="container"> <div class="label">width</div> <div class="slider"> <div class="slider__view">10</div><input class="slider" oninput="sliderInput(event)" type="range" min="0" max="100" value="10"> </div> </div> <div class="container"> <div class="label">height</div> <div class="slider"> <div class="slider__view">10</div><input class="slider" oninput="sliderInput(event)" type="range" min="0" max="100" value="10"> </div> </div> </div> </div>');
div.insertAdjacentHTML('beforeEnd', '<div class="game"> <table id="board"></table> <div id="controls"><button class="standart-button standart-button_ standart-button_small standart-button_-small">start</button><button class="standart-button standart-button_ standart-button_small standart-button_-small">pause</button><button class="standart-button standart-button_ standart-button_small standart-button_-small">clear</button> <div class="container"> <div class="label">speed</div> <div class="slider"> <div class="slider__view">1</div><input class="slider" oninput="sliderInput(event)" type="range" min="1" max="10" value="1"> </div> </div> <div class="container"> <div class="label">width</div> <div class="slider"> <div class="slider__view">10</div><input class="slider" oninput="sliderInput(event)" type="range" min="0" max="100" value="10"> </div> </div> <div class="container"> <div class="label">height</div> <div class="slider"> <div class="slider__view">10</div><input class="slider" oninput="sliderInput(event)" type="range" min="0" max="100" value="10"> </div> </div> </div> </div>');
document.body.appendChild(div);
it('проверка', function () {
assert.notEqual(document.getElementsByClassName('game'), null, 'game not in DOM');
Expand All @@ -18,7 +17,6 @@ describe('контроллер', function () {

describe('Создание контроллера', function () {
controller = new Controller();
console.log(controller.table);
it('находит таблицу', function () {
assert.equal(controller.table !== undefined, true);
});
Expand All @@ -33,7 +31,7 @@ describe('контроллер', function () {
});
it('создает свойства', function () {
assert.equal(controller.running === false, true);
assert.equal(controller.fps, 1)
assert.equal(controller.fps, 1);
});
});

Expand Down Expand Up @@ -66,20 +64,20 @@ describe('контроллер', function () {
});
it('клик по кнопке start', function (done) {
const button = controller.controls.children[0];
assert.equal(controller.running,false, 'before false');
assert.equal(controller.running, false, 'before false');
button.click();
assert.equal(button.disabled && controller.running,true,'after true');
assert.equal(button.disabled && controller.running, true, 'after true');
controller.running = false;
setTimeout(done,1000);
setTimeout(done, 1000);
});
it('клик по кнопке pause',function () {
it('клик по кнопке pause', function () {
const button = controller.controls.children[1];
controller.running = true;
assert.equal((!button.disabled && controller.running),true,'before true');
assert.equal((!button.disabled && controller.running), true, 'before true');
button.click();
assert.equal((button.disabled && !controller.running),true,'after false');
assert.equal((button.disabled && !controller.running), true, 'after false');
});
it('клик по кнопке clear',function () {
it('клик по кнопке clear', function () {
const board = controller.board;
const button = controller.controls.children[2];
controller.running = true;
Expand All @@ -89,11 +87,11 @@ describe('контроллер', function () {
assert.equal((!button.disabled && !board.matrix[0][0] && !controller.running),true,'after false');

});
it('слайдер speed',function () {
it('слайдер speed', function () {
const slider = document.querySelectorAll('input.slider')[0];
slider.value = 5;
controller.slidersChange({target: slider});
assert.equal(controller.fps,5)
assert.equal(controller.fps,5);
});
it('слайдер Width',function () {
const slider = document.querySelectorAll('input.slider')[1];
Expand Down
103 changes: 50 additions & 53 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,56 @@
/**
* Created by DNS on 07.11.2017.
*/
var webpackConfig = require('./testing.webpack');
module.exports=function(config) {
config.set({
browsers: [ 'Chrome' ],
hostname: 'localhost',
port: 9050,
browserNoActivityTimeout: 60000,
//singleRun: true, //just run once by default
module.exports = function (config) {
config.set({
browsers: [ 'Chrome' ],
hostname: 'localhost',
port: 9050,
browserNoActivityTimeout: 60000,
// singleRun: true, //just run once by default

// конфигурация репортов о покрытии кода тестами
coverageReporter: {
dir:'tmp/coverage/',
reporters: [
{ type:'html', subdir: 'report-html' },
{ type:'lcov', subdir: 'report-lcov' }
],
instrumenterOptions: {
istanbul: { noCompact:true }
}
},
// spec файлы, условимся называть по маске **_*.spec.js_**
files: [
'frontend/**/*.spec.js',
// конфигурация репортов о покрытии кода тестами
coverageReporter: {
dir: 'tmp/coverage/',
reporters: [
{ type: 'html', subdir: 'report-html' },
{ type: 'lcov', subdir: 'report-lcov' }
],
instrumenterOptions: {
istanbul: { noCompact: true }
}
},
// spec файлы, условимся называть по маске **_*.spec.js_**
files: [
'frontend/**/*.spec.js',
],
frameworks: ['chai', 'jasmine'],
// репортеры необходимы для наглядного отображения результатов
reporters: ['mocha', 'coverage'],
preprocessors: {
'frontend/**/*.spec.js': ['webpack', 'babel', 'sourcemap','coverage']
},
babelPreprocessor: {
options: {
presets: ['env'],
sourceMap: 'inline'
},
filename: function (file) {
return file.originalPath.replace(/\.js$/, '.es5.js');
},
sourceFileName: function (file) {
return file.originalPath;
}
},
plugins: [
'karma-jasmine', 'karma-mocha',
'karma-chai', 'karma-coverage',
'karma-webpack', 'karma-phantomjs-launcher',
'karma-mocha-reporter', 'karma-sourcemap-loader',
'karma-babel-preprocessor'
],
// передаем конфигурацию webpack
webpack: webpackConfig,
webpackMiddleware: {
noInfo:true
}
});
frameworks: ['chai', 'jasmine'],
// репортеры необходимы для наглядного отображения результатов
reporters: ['mocha', 'coverage'],
preprocessors: {
'frontend/**/*.spec.js': ['webpack', 'babel', 'sourcemap','coverage']
},
babelPreprocessor: {
options: {
presets: ['env'],
sourceMap: 'inline'
},
filename: function (file) {
return file.originalPath.replace(/\.js$/, '.es5.js');
},
sourceFileName: function (file) {
return file.originalPath;
}
},
plugins: [
'karma-jasmine', 'karma-mocha',
'karma-chai', 'karma-coverage',
'karma-webpack', 'karma-phantomjs-launcher',
'karma-mocha-reporter', 'karma-sourcemap-loader',
'karma-babel-preprocessor'
],
webpackMiddleware: {
noInfo: true
}
});
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"license": "ISC",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"chai": "^4.1.2",
"css-loader": "^0.28.7",
Expand Down
68 changes: 0 additions & 68 deletions testing.webpack.js

This file was deleted.

Loading

0 comments on commit 5377cac

Please sign in to comment.