Skip to content

Commit a95881e

Browse files
committed
change store to object, run test results in console
1 parent fcc873a commit a95881e

File tree

10 files changed

+37
-50
lines changed

10 files changed

+37
-50
lines changed

lib/components/Test/Result.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,7 @@ var __extends = (this && this.__extends) || function (d, b) {
44
function __() { this.constructor = d; }
55
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
66
};
7-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
8-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11-
return c > 3 && r && Object.defineProperty(target, key, r), r;
12-
};
13-
var __metadata = (this && this.__metadata) || function (k, v) {
14-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
15-
};
167
var React = require('react');
17-
var react_redux_1 = require('react-redux');
188
var Card_1 = require('material-ui/Card');
199
var styles = {
2010
card: {
@@ -30,16 +20,10 @@ var Result = (function (_super) {
3020
var result = this.props.result;
3121
return (React.createElement(Card_1.Card, {style: styles.card, initiallyExpanded: true},
3222
React.createElement(Card_1.CardText, {expandable: true},
33-
React.createElement("p", null, result.msg)
23+
React.createElement("p", null, "Check the console.")
3424
)
3525
));
3626
};
37-
Result = __decorate([
38-
react_redux_1.connect(function (state) { return ({
39-
result: state.result,
40-
}); }),
41-
__metadata('design:paramtypes', [])
42-
], Result);
4327
return Result;
4428
}(React.Component));
4529
Object.defineProperty(exports, "__esModule", { value: true });

lib/components/Test/Solution.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ var RaisedButton_1 = require('material-ui/RaisedButton');
2020
var index_1 = require('../index');
2121
var actions_1 = require('../../actions');
2222
var core_coderoad_1 = require('core-coderoad');
23-
var Result_1 = require('./Result');
2423
var styles = {
2524
card: {
2625
margin: '5px',
@@ -54,7 +53,9 @@ var Solution = (function (_super) {
5453
React.createElement("div", {style: styles.buttons},
5554
React.createElement(RaisedButton_1.default, {label: 'Run Test', primary: true, onTouchTap: this.runTest.bind(this)})
5655
),
57-
React.createElement(Result_1.default, null))));
56+
React.createElement("br", null),
57+
React.createElement("br", null),
58+
React.createElement("p", null, "Check the console for test results."))));
5859
};
5960
Solution = __decorate([
6061
react_redux_1.connect(function (state) { return ({

lib/modules/runner/handleResult.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"use strict";
2-
var store_1 = require('../../store');
3-
var actions_1 = require('../../actions');
42
function handleResult(result) {
5-
console.log('handleResult', result);
6-
return store_1.default.dispatch(actions_1.testResult(result));
3+
var msg = result.msg, change = result.change;
4+
console.log({
5+
msg: msg,
6+
passed: change > 0,
7+
});
78
}
89
Object.defineProperty(exports, "__esModule", { value: true });
910
exports.default = handleResult;

lib/modules/runner/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use strict";
22
var loadRunner_1 = require('./loadRunner');
3+
var handleResult_1 = require('./handleResult');
34
var RUNNER_SET = 'RUNNER_SET';
45
var RUNNER_RUN = 'RUNNER_RUN';
56
function runnerSet() {
@@ -24,9 +25,6 @@ var r = function (content) {
2425
console.log(content);
2526
alert('Runner not yet implemented.');
2627
};
27-
function handleResult(result) {
28-
console.log('handleResult', result);
29-
}
3028
function reducer(runner, action) {
3129
if (runner === void 0) { runner = r; }
3230
switch (action.type) {
@@ -35,7 +33,7 @@ function reducer(runner, action) {
3533
return loadRunner_1.default(dir, name_2);
3634
case RUNNER_RUN:
3735
var _b = action.payload, content = _b.content, config = _b.config;
38-
runner(content, config, handleResult);
36+
runner(content, config, handleResult_1.default);
3937
return runner;
4038
default:
4139
return runner;

lib/store.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
"use strict";
22
var reducers_1 = require('./reducers');
33
var core_coderoad_1 = require('core-coderoad');
4+
var store = core_coderoad_1.configureStore({
5+
reducer: reducers_1.default,
6+
devMode: false,
7+
throttle: { TUTORIAL_BUILD: 300 },
8+
});
49
Object.defineProperty(exports, "__esModule", { value: true });
5-
exports.default = core_coderoad_1.configureStore(reducers_1.default, false, { TUTORIAL_BUILD: 300 });
10+
exports.default = store;

src/components/Test/Result.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import {connect} from 'react-redux';
2+
// import {connect} from 'react-redux';
33
import {Card, CardText, CardTitle} from 'material-ui/Card';
44
import RaisedButton from 'material-ui/RaisedButton';
55

@@ -9,9 +9,9 @@ const styles = {
99
},
1010
};
1111

12-
@connect(state => ({
13-
result: state.result,
14-
}))
12+
// @connect(state => ({
13+
// result: state.result,
14+
// }))
1515
export default class Result extends React.Component <{
1616
result?: Object
1717
}, {}> {
@@ -23,7 +23,7 @@ export default class Result extends React.Component <{
2323
initiallyExpanded={true}
2424
>
2525
<CardText expandable={true}>
26-
<p>{result.msg}</p>
26+
<p>Check the console.</p>
2727
</CardText>
2828
</Card>
2929
);

src/components/Test/Solution.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ ${atom.workspace.getActiveTextEditor().getText()}
6969
onTouchTap={this.runTest.bind(this)}
7070
/>
7171
</div>
72-
73-
<Result />
72+
<br />
73+
<br />
74+
<p>Check the console for test results.</p>
75+
{/*}<Result />*/}
7476
</CardText>
7577
</Card>
7678
);

src/modules/runner/handleResult.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import store from '../../store';
22
import {testResult} from '../../actions';
33

44
export default function handleResult(result) {
5-
console.log('handleResult', result);
6-
return store.dispatch(testResult(result));
5+
const {msg, change} = result;
6+
console.log({
7+
msg,
8+
passed: change > 0,
9+
});
710
}

src/modules/runner/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import loadRunner from './loadRunner';
2-
// import handleResult from './handleResult';
3-
import store from '../../store';
2+
import handleResult from './handleResult';
43
import {testResult} from '../../actions';
54

65
const RUNNER_SET = 'RUNNER_SET';
@@ -30,11 +29,6 @@ const r = (content: string) => {
3029
alert('Runner not yet implemented.');
3130
};
3231

33-
function handleResult(result) {
34-
console.log('handleResult', result);
35-
// return store.dispatch(testResult(result));
36-
}
37-
3832
export function reducer(runner = r, action: Action) {
3933
switch (action.type) {
4034

src/store.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import reducer from './reducers';
22
import {configureStore} from 'core-coderoad';
33

4-
export default configureStore(
4+
const store = configureStore({
55
reducer,
6-
// devMode
7-
false,
8-
// throttled actions
9-
{ TUTORIAL_BUILD: 300 }
10-
);
6+
devMode: false,
7+
throttle: { TUTORIAL_BUILD: 300 },
8+
});
9+
export default store;

0 commit comments

Comments
 (0)