mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-10 23:12:09 +01:00
Ability to launch unit tests using carma and webpack
This commit is contained in:
@@ -1,20 +1,40 @@
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
frameworks: ['jasmine'],
|
||||
|
||||
files: [
|
||||
'src.old/js/core/core.js',
|
||||
'src.old/js/core/is.js',
|
||||
'src.old/js/core/di.js',
|
||||
'src.old/js/core/should.js',
|
||||
'src.old/js/core/htmlBuilder.js',
|
||||
'src.old/js/core/should.js',
|
||||
'src.old/js/core/appShell.js',
|
||||
'src.old/js/core/observable.js',
|
||||
'src.old/js/app.js',
|
||||
'src.old/js/components/*.js',
|
||||
'src.old/js/app/**/*.js',
|
||||
'tests/unit/**/*.js'
|
||||
]
|
||||
});
|
||||
};
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
browsers: [ 'Chrome' ],
|
||||
// karma only needs to know about the test bundle
|
||||
files: [
|
||||
'./tests/unit/**/*.js'
|
||||
],
|
||||
frameworks: [ 'jasmine' ],
|
||||
plugins: [
|
||||
'karma-chrome-launcher',
|
||||
'karma-jasmine',
|
||||
'karma-webpack',
|
||||
],
|
||||
// run the bundle through the webpack and sourcemap plugins
|
||||
preprocessors: {
|
||||
'./tests/unit/**/*.js': [ 'webpack']
|
||||
},
|
||||
reporters: [ 'dots' ],
|
||||
singleRun: true,
|
||||
// webpack config object
|
||||
webpack: {
|
||||
module: {
|
||||
loaders: [
|
||||
{
|
||||
exclude: /node_modules/,
|
||||
loader: 'babel-loader',
|
||||
test: /\.jsx?$/,
|
||||
query: {
|
||||
presets: [require.resolve('babel-preset-es2015'), require.resolve('babel-preset-react')],
|
||||
plugins: [require.resolve('babel-plugin-transform-class-properties')]
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
},
|
||||
webpackMiddleware: {
|
||||
noInfo: true,
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -8,7 +8,8 @@
|
||||
"serv": "webpack-dev-server --content-base ./src",
|
||||
"e2e": "protractor ./tests/e2e.chrome.js --params.appUrl='http://localhost:8080/#clear'",
|
||||
"e2e_build": "protractor ./tests/e2e.chrome.js --params.appUrl='http://localhost:3000/#clear'",
|
||||
"e2e_remote": "protractor ./tests/e2e.chrome.js --params.appUrl='http://bitwisecmd.com/react/#clear'"
|
||||
"e2e_remote": "protractor ./tests/e2e.chrome.js --params.appUrl='http://bitwisecmd.com/react/#clear'",
|
||||
"test": "karma start"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -35,6 +36,7 @@
|
||||
"jasmine": "latest",
|
||||
"karma": "latest",
|
||||
"karma-jasmine": "latest",
|
||||
"karma-webpack": "latest",
|
||||
"source-map-loader": "^0.1.5",
|
||||
"ts-loader": "^1.0.0"
|
||||
},
|
||||
|
||||
@@ -34,11 +34,7 @@ var expression = {
|
||||
},
|
||||
addFactory: function(factory) {
|
||||
this.factories.push(factory);
|
||||
},
|
||||
Operand:Operand,
|
||||
SingleOperandExpression: SingleOperandExpression,
|
||||
ListOfNumbersExpression: ListOfNumbersExpression,
|
||||
MultipleOperandsExpression: MultipleOperandsExpression
|
||||
}
|
||||
};
|
||||
|
||||
// List of numbers
|
||||
|
||||
@@ -8,15 +8,16 @@ export default {
|
||||
getArgs: function (hashValue) {
|
||||
|
||||
var decodedHash = this.decodeHash(hashValue),
|
||||
args = [];
|
||||
args = { commands: [] };
|
||||
|
||||
splitHashList(decodedHash).forEach(function(value) {
|
||||
// Support for -debur or -notrack properties
|
||||
if(/^\-[a-zA-Z]+$/.test(value)) {
|
||||
args[value.substr(1)] = true;
|
||||
return;
|
||||
}
|
||||
|
||||
args.push(value);
|
||||
args.commands.push(value);
|
||||
});
|
||||
|
||||
return Object.freeze(args);
|
||||
|
||||
@@ -20,8 +20,9 @@ console.log("appState", appState);
|
||||
|
||||
var hashArgs = hash.getArgs(window.location.hash);
|
||||
var startupCommands = ['help', '1|2&6','1<<0x2a','2 4 8 16 32'];
|
||||
if(hashArgs.length > 0) {
|
||||
startupCommands = hashArgs;
|
||||
|
||||
if(hashArgs.commands.length > 0) {
|
||||
startupCommands = hashArgs.commands;
|
||||
}
|
||||
|
||||
startupCommands.forEach(cmd.execute.bind(cmd));
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
rem /S Copy folders and subfolders
|
||||
rem /Y Suppress prompt to confirm overwriting a file.
|
||||
|
||||
xcopy .\build\*.* ..\BitwiseCmdPages\ /S /Y
|
||||
@@ -1,13 +1,12 @@
|
||||
var app = window.app;
|
||||
var expression = app.get('expression');
|
||||
var expression = require('../../src/app/expression');
|
||||
var parser = expression.parser;
|
||||
|
||||
describe("expression parse", function() {
|
||||
describe("expression parser", function() {
|
||||
|
||||
var shouldParse = ['0x2>>1', '1 2 3', '0x1 1 2 3 5', '0x1>>0x2', '1|2', '-9', '-1|-2', '~3'];
|
||||
|
||||
it("should be able to parse", function() {
|
||||
shouldParse.forEach(function(expr) {
|
||||
expect(expression.canParse(expr)).toBe(true, 'expr: ' + expr);
|
||||
expect(parser.canParse(expr)).toBe(true, 'expr: ' + expr);
|
||||
})
|
||||
});
|
||||
|
||||
@@ -29,7 +28,7 @@ describe("expression parse", function() {
|
||||
|
||||
for(input in expressionCases) {
|
||||
console.log('case: ' + input);
|
||||
var actual = expression.parse(input);
|
||||
var actual = parser.parse(input);
|
||||
var expected = expressionCases[input];
|
||||
expect(actual).toBeDefined();
|
||||
expect(actual).not.toBe(null);
|
||||
@@ -58,7 +57,7 @@ describe("expression parse", function() {
|
||||
it("should parse hexadecimal expressions", function() {
|
||||
var input, i;
|
||||
for(input in listCases) {
|
||||
var actual = expression.parse(input);
|
||||
var actual = parser.parse(input);
|
||||
var expected = listCases[input];
|
||||
|
||||
for(i =0; i<expected.length;i++) {
|
||||
@@ -69,26 +68,26 @@ describe("expression parse", function() {
|
||||
});
|
||||
|
||||
it ("should parse multiple operands expression", function () {
|
||||
var actual = expression.parse("1|2&3");
|
||||
var actual = parser.parse("1|2&3");
|
||||
})
|
||||
});
|
||||
|
||||
describe('parse operands', function() {
|
||||
|
||||
var hexOperand = expression.parseOperand('0x10');
|
||||
var decOperand = expression.parseOperand('10');
|
||||
var hexOperand = parser.parseOperand('0x10');
|
||||
var decOperand = parser.parseOperand('10');
|
||||
rundOperandsTest(hexOperand, decOperand);
|
||||
});
|
||||
|
||||
describe('create operands', function() {
|
||||
|
||||
var hexOperand = expression.createOperand(0x10, 'hex');
|
||||
var decOperand = expression.createOperand(10, 'dec');
|
||||
var hexOperand = parser.createOperand(0x10, 'hex');
|
||||
var decOperand = parser.createOperand(10, 'dec');
|
||||
rundOperandsTest(hexOperand, decOperand);
|
||||
});
|
||||
|
||||
describe('negative operands', function () {
|
||||
var op = expression.parseOperand('-0xa');
|
||||
var op = parser.parseOperand('-0xa');
|
||||
it('shoold have correct values', function() {
|
||||
expect(op.value).toBe(-10);
|
||||
expect(op.hex).toBe('-0xa');
|
||||
@@ -112,8 +111,6 @@ describe('should format to kind strings', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function rundOperandsTest(hexOperand, decOperand) {
|
||||
it('should remember input form', function() {
|
||||
expect(hexOperand.input).toBe('0x10');
|
||||
@@ -1,6 +1,6 @@
|
||||
var formatter = require('../../src/app/formatter');
|
||||
|
||||
describe('expression formatter', function () {
|
||||
var di = app.di.clone();
|
||||
var formatter = di.resolve('formatter');
|
||||
|
||||
xit('should format number to binary by default', function() {
|
||||
expect(formatter.formatString(10)).toBe("1010");
|
||||
@@ -1,5 +1,6 @@
|
||||
var hash = require('../../src/app/hash').default;
|
||||
|
||||
describe('hash arguments parser', function() {
|
||||
var hash = app.get('hash');
|
||||
|
||||
it('should parse empty', function() {
|
||||
var args = hash.getArgs('');
|
||||
@@ -53,7 +54,4 @@ describe('hash arguments parser', function() {
|
||||
expect(args.notrack).toBe(true);
|
||||
expect(args.debug).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user