Skip to content

Commit d5309c2

Browse files
committed
Test results will display properly in the instructions section after user runs examples.
1 parent 61ab1b5 commit d5309c2

6 files changed

Lines changed: 33 additions & 10 deletions

File tree

src/assets/scss/styles.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ main {
9898
font-weight: 400;
9999
}
100100

101+
.font12-reg-black {
102+
color: #131414;
103+
font-family: $font;
104+
font-size: 12px;
105+
line-height: 12px;
106+
font-weight: 400;
107+
}
108+
101109
.side-menu {
102110
background-color: $sidebar-color;
103111
height: 100vh;
@@ -171,4 +179,4 @@ padding: 75px 75px 10px 75px;
171179

172180
a {
173181
text-decoration: none;
174-
}
182+
}

src/components/mainService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ angular.module('app').service('mainService', function($http, $q, $sce) {
22

33
// $sce.trustAsResourceUrl('/s');
44

5-
this.testExamples = function(solution, examples, kataid) {
5+
this.testExamples = function(solution, examples) {
66
return $http({
77
method: 'POST',
8-
url: `/test/examples/${kataid}`,
8+
url: `http://192.168.0.186:3030/test/examples`,
99
data: {
1010
script: solution,
1111
examples: examples
@@ -16,7 +16,7 @@ angular.module('app').service('mainService', function($http, $q, $sce) {
1616
this.testSuite = function(solution, kataid) {
1717
return $http({
1818
method: 'POST',
19-
url: `/test/${kataid}`,
19+
url: `/test/suite/${kataid}`,
2020
data: {
2121
script: solution
2222
}

src/components/training/training.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ <h3 class="font16-reg" id="kata-name">
4949
<h2 class="font20-reg">Name of Kata</h2>
5050
<div>
5151
<p>Here's where the instructions go. We have to think about how to present code samples.</p>
52+
<div ng-repeat="test in output">
53+
<p>{{test.test}}</p>
54+
<p>{{test.result}}</p>
55+
</div>
5256
</div>
5357
</div>
5458

@@ -57,15 +61,16 @@ <h2 class="font20-reg">Name of Kata</h2>
5761
<div class="solution-div">
5862
<p>Solution:</p>
5963
<form>
60-
Function: <textarea name="solution" cols="40" rows="5" id="solution-input" ng-model="solutionInput"></textarea>
64+
Function: <textarea name="solution" cols="40" rows="5" id="solution-input" ng-init="solutionInput = 'var a = 1;'"ng-model="solutionInput"></textarea>
6165
</form>
6266
</div>
6367

6468
<div class="example-tests-div">
6569
<p>Example Tests:</p>
6670
<form>
67-
<textarea name="examples" cols="40" rows="5" id="example-tests-input" ng-model="examplesInput"></textarea>
68-
<button ng-click="testExamples(solutionInput, examplesInput)" class="run-examples-button font12-reg-blue">RUN EXAMPLES</button>
71+
<textarea name="examples" cols="40" rows="5" ng-init="examplesInput = 'Test.assertEquals(a, 1);'" id="example-tests-input" ng-model="examplesInput"></textarea>
72+
<button ng-click="testExamples(solutionInput, examplesInput)" class="test-examples-button font12-reg-blue">RUN EXAMPLES</button>
73+
<button ng-click="testSuite(solutionInput)" class="test-suite-button font12-reg-black" style=""><i class="fa fa-caret-right fa-lg" style="margin-right: 2px" aria-hidden="true"></i>ATTEMPT</button>
6974
</form>
7075
</div>
7176

src/components/training/training.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,22 @@ hr {
9696
width: 40vw;
9797
}
9898

99-
.run-examples-button {
99+
.test-examples-button {
100100
border: 1px solid #91b2e7;
101101
border-radius: 4%;
102102
width: 113px;
103103
height: 30px;
104104
background-color: #3C3C3C;
105105
}
106106

107+
.test-suite-button {
108+
border: 1px solid #91b2e7;
109+
border-radius: 4%;
110+
width: 113px;
111+
height: 30px;
112+
background-color: #91b2e7;
113+
}
114+
107115
.training-body {
108116
background-color: red;
109117
}

src/components/training/trainingCtrl.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ angular.module('app').controller('trainingCtrl', function($scope, $state, mainSe
44

55
$scope.languages = ['JavaScript', 'Python'];
66
$scope.versions = ['Node v0.10.33', 'Node v6.6.0'];
7+
$scope.output = [];
78

89

910
//Examples should be an array of objects. Returned results will be an array with the different tests and their results.
@@ -12,10 +13,10 @@ angular.module('app').controller('trainingCtrl', function($scope, $state, mainSe
1213
let examplesArr = [];
1314
examples = examples.split(/\n/);
1415
examples.forEach(example => examplesArr.push({test: example}));
15-
console.log(solutions, examplesArr);
16-
// mainService.testExamples(solutionsInput, examplesArr, kataid).then((response) => console.log(response));
16+
mainService.testExamples(solutions, examplesArr).then((response) => $scope.output.push(response.data[0]));
1717
}
1818

19+
1920
$scope.testSuite = function(solutions) {
2021
solutions = solutions.replace(/\n/g, " ");
2122
// mainService.testSuite(solutions, kataid).then((response) => console.log(response));

src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
</body>
2424
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
2525
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.js"></script>
26+
<script src="https://use.fontawesome.com/b3416c175c.js"></script>
2627
<script type='text/javascript' src='./bundle.js'></script>
2728

2829
</html>

0 commit comments

Comments
 (0)