mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2026-01-23 20:24:13 +01:00
Fix unit test
This commit is contained in:
@@ -9,7 +9,7 @@ import ExpressionResultView from './results/ExpressionResultView';
|
||||
import WhatsnewResult from '../models/WhatsnewResult';
|
||||
import WhatsnewResultView from './results/WhatsnewResultView';
|
||||
import ErrorResult from '../models/ErrorResult';
|
||||
import expression from '../../expression';
|
||||
import * as expression from '../expression';
|
||||
|
||||
export default class DisplayResult extends React.Component {
|
||||
render() {
|
||||
@@ -22,18 +22,6 @@ export default class DisplayResult extends React.Component {
|
||||
</div>;
|
||||
}
|
||||
|
||||
renderUnknown() {
|
||||
return <div className="result">
|
||||
<div className="error">¯\_(ツ)_/¯ Sorry, i don′t know what <strong>{this.props.input}</strong> is</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
renderError(message) {
|
||||
return <div className="result">
|
||||
<div className="error">(X_X) Error occurred: <strong>{message}</strong></div>
|
||||
</div>
|
||||
}
|
||||
|
||||
findResultComponent(result) {
|
||||
if(result instanceof HelpResult) {
|
||||
return <HelpResultView content={result} />
|
||||
@@ -51,14 +39,14 @@ export default class DisplayResult extends React.Component {
|
||||
return <WhatsnewResultView />
|
||||
}
|
||||
|
||||
if (result instanceof expression.ExpressionError) {
|
||||
return this.renderError(result.message);
|
||||
if (result instanceof ErrorResult) {
|
||||
return <div className="result">
|
||||
<div className="error">(X_X) Ooops.. Something ain' right: <strong>{result.error.message}</strong></div>
|
||||
</div>
|
||||
}
|
||||
|
||||
if (result instanceof Error) {
|
||||
return this.renderError(result.message);
|
||||
}
|
||||
|
||||
return this.renderUnknown();
|
||||
return <div className="result">
|
||||
<div className="error">¯\_(ツ)_/¯ Sorry, i don′t know what <strong>{this.props.input}</strong> is</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import Operand from './expression/operand';
|
||||
export { default as Operand } from './expression/operand';
|
||||
export { default as ExpressionError } from './expression/ExpressionError';
|
||||
|
||||
var expression = {
|
||||
factories:[],
|
||||
|
||||
@@ -72,7 +72,7 @@ export default class Operand {
|
||||
var parsed = numberParser.parse(input);
|
||||
|
||||
if(!parsed) {
|
||||
throw new ExpressionError("Unknown number: " + input);
|
||||
throw new ExpressionError(input + " is not a valid number");
|
||||
}
|
||||
|
||||
return new Operand(parsed);
|
||||
|
||||
Reference in New Issue
Block a user