mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-10 06:52:05 +01:00
add support of commads from location hash
This commit is contained in:
2
e2e.sh
Normal file
2
e2e.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
protractor ./tests/e2e.chrome.js --params.appUrl="http://localhost:8080"
|
||||
@@ -12,11 +12,7 @@ export default class AppRoot extends React.Component {
|
||||
}
|
||||
|
||||
getIndicator(value) {
|
||||
if(value) {
|
||||
return "on";
|
||||
}
|
||||
|
||||
return "off";
|
||||
return value === true ? 'on' : 'off';
|
||||
}
|
||||
|
||||
getResultViews() {
|
||||
|
||||
@@ -9,7 +9,7 @@ export default class InputBox extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
return <input type="text"
|
||||
return <input id="in" type="text"
|
||||
onKeyUp={e => this.onKeyUp(e)}
|
||||
onKeyDown={e => this.onKeyDown(e)}
|
||||
className="expressionInput mono"
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import formatter from '../../formatter';
|
||||
import BinaryStringView from './BinaryStringView';
|
||||
import BitwiseExpressionViewModel from './models/BitwiseExpressionViewModel'
|
||||
//import calc from '../../calc';
|
||||
|
||||
|
||||
export default class ListOfNumersExpressionView extends React.Component {
|
||||
render() {
|
||||
|
||||
@@ -7,7 +7,7 @@ export default class BitwiseExpressionViewModel {
|
||||
}
|
||||
|
||||
static buildMultiple (expr, config) {
|
||||
console.log(config);
|
||||
|
||||
var op = expr.expressions[0],
|
||||
i = 1, l = expr.expressions.length,
|
||||
ex, m = new BitwiseExpressionViewModel(config);
|
||||
@@ -30,8 +30,8 @@ export default class BitwiseExpressionViewModel {
|
||||
return m;
|
||||
};
|
||||
|
||||
static buildNot (expression, cofig) {
|
||||
console.log(config);
|
||||
static buildNot (expression, config) {
|
||||
|
||||
var m = new BitwiseExpressionViewModel(config);
|
||||
m.addExpression(expression);
|
||||
m.addExpressionResult(expression.apply());
|
||||
|
||||
40
src/app/hash.js
Normal file
40
src/app/hash.js
Normal file
@@ -0,0 +1,40 @@
|
||||
export default {
|
||||
encodeHash: function(string) {
|
||||
return encodeURI(string.trim().replace(/\s/g,','));
|
||||
},
|
||||
decodeHash: function(hashValue) {
|
||||
return decodeURI(hashValue).replace(/^\#/, '').replace(/,/g,' ');
|
||||
},
|
||||
getArgs: function (hashValue) {
|
||||
|
||||
var decodedHash = this.decodeHash(hashValue),
|
||||
args = [];
|
||||
|
||||
splitHashList(decodedHash).forEach(function(value) {
|
||||
if(/^\-[a-zA-Z]+$/.test(value)) {
|
||||
args[value.substr(1)] = true;
|
||||
return;
|
||||
}
|
||||
|
||||
args.push(value);
|
||||
});
|
||||
|
||||
return Object.freeze(args);
|
||||
}
|
||||
};
|
||||
|
||||
function splitHashList(str) {
|
||||
var values = [];
|
||||
|
||||
if(str.indexOf('||')) {
|
||||
str.split('||').forEach(function (v) {
|
||||
if (v.length > 0) {
|
||||
values.push(v);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
values.push(str);
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import appStateStore from './appStateStore';
|
||||
import cmd from './cmd';
|
||||
import commands from './commands';
|
||||
import AppRoot from './components/AppRoot';
|
||||
import hash from './hash';
|
||||
|
||||
|
||||
var stateData = appStateStore.getPersistedData();
|
||||
@@ -17,9 +18,14 @@ commands.initialize(cmd, appState);
|
||||
|
||||
console.log("appState", appState);
|
||||
|
||||
cmd.execute('1');
|
||||
cmd.execute('2');
|
||||
cmd.execute('1|2<<2');
|
||||
|
||||
var hashArgs = hash.getArgs(window.location.hash);
|
||||
var startupCommands = ['1','2','1|2<<2'];
|
||||
if(hashArgs.length > 0) {
|
||||
startupCommands = hashArgs;
|
||||
}
|
||||
|
||||
startupCommands.forEach(cmd.execute.bind(cmd));
|
||||
|
||||
var root = <AppRoot appState={appState} />;
|
||||
ReactDOM.render(root, document.getElementById('root'));
|
||||
@@ -7,7 +7,7 @@ var driver = browser.driver;
|
||||
var appUrl = browser.params.appUrl || 'http://localhost:63342/BitwiseCmd/src/#clear';
|
||||
var sutPage = new BitwiseCmdPage(driver, appUrl);
|
||||
|
||||
describe('launch of application', function() {
|
||||
describe('when application starts', function() {
|
||||
it('should have title', function() {
|
||||
sutPage.goToApp().then(function() {
|
||||
expect(driver.getTitle()).toEqual('BitwiseCmd');
|
||||
@@ -149,15 +149,15 @@ describe('launch of application', function() {
|
||||
|
||||
});
|
||||
|
||||
xit('should emphasize bytes', function() {
|
||||
it('should emphasize bytes', function() {
|
||||
|
||||
goToApp()
|
||||
sutPage.goToApp()
|
||||
.then(function() { return sutPage.executeExpression('1')})
|
||||
.then(function() {
|
||||
return assertExpressionResult([{ label: '1', bin:'00000001', other: '0x1'}])
|
||||
})
|
||||
.then(function() { return sutPage.executeExpression('clear')})
|
||||
// .then(function() { return sendCommand('em')})
|
||||
.then(function() { return sutPage.executeExpression('em')})
|
||||
.then(function() { return sutPage.shouldHaveNoErrors(); })
|
||||
.then(function() { return sutPage.executeExpression('1 3')})
|
||||
.then(function() {
|
||||
|
||||
Reference in New Issue
Block a user