Skip to content

Commit 1971b13

Browse files
committed
Add very basic unit tests, add to README
1 parent 83540ad commit 1971b13

File tree

4 files changed

+85
-2
lines changed

4 files changed

+85
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If you are anxious to join the fight (and who wouldn't be), then all you need to
1616
* After signing up, navigate back to this page and at the top right of your screen, click the 'Fork' button.
1717
* When you click the 'Fork' button, you will be asked where you want to fork this repo. Go ahead and click your username. This will effectively copy this repo into yours.
1818
* BAM!!! Now, you have a working repo in your account! Nice!
19-
* The only thing left to do is navigate to the [Javascript Battle](http://javascriptbattle.com/) website and sign up. Make sure you tell us the name of your repo.
19+
* The only thing left to do is navigate to the [Javascript Battle](http://javascriptbattle.com/) website and sign up. Make sure you tell us the name of your repo (we will assume it is called "hero-starter" unless you tell us differently on your user page).
2020
* **Hint** - You can find this info by looking at the url when you are in your repo. For example, the url for my repo is 'github.com/forrestbthomas/hero-starter'. My username is 'forrestbthomas' and my repo name is 'hero-starter'.
2121
* At this point, you have a working repo, with working hero code and you can watch your hero tilt with the best in tomorrow's battle. Once you are ready, you can begin diving in to the code, to make your hero even stronger and make Javascript Battle even more glorious!
2222

@@ -25,6 +25,7 @@ If you are anxious to join the fight (and who wouldn't be), then all you need to
2525
1. Cloning, Adding and Committing
2626
2. The Hero's Brain
2727
3. Pushing and Waiting
28+
4. Testing your hero code
2829

2930
####Cloning, Adding and Committing####
3031
You already have a working hero. You have watched the epic-ness that is your champion battling against other noble heroes. However, there comes a time in every hero's journey, when training becomes necessary.
@@ -111,7 +112,7 @@ This allows our site to pull this code from your repo and use it in tomorrow's g
111112
Once you have changed your hero to be the ultimate Javascript champion, you will need to push your changes to GitHub.
112113

113114
######Steps######
114-
* On the command line, navigate to your hero directory.
115+
* On the command line, navigate to your hero code directory.
115116
* After adding and committing your changes, type in the following command:
116117
```
117118
git push origin master
@@ -124,3 +125,29 @@ git push origin master
124125
[Stop by](http://javascriptbattle.com/#page-top) the site tomorrow and see how your hero did. We encourage you to continue to make changes to your hero repo as often as you like. We hope this experience will both be an enjoyable and instructive experience.
125126

126127
If we can make our site better in any way or make any instructions or code more explicit, please let us know. Until then, may the javascripts be with you!
128+
129+
####Testing####
130+
131+
We have a testing site coming soon. For now, though, you can still test your hero code on your own! There are two ways to do this:
132+
133+
######Option 1: Make sure your code doesn't have errors######
134+
135+
* On the command line, navigate to your hero code directory.
136+
* After making sure you have Node and NPM installed, type in the following commands:
137+
```
138+
npm install
139+
npm test
140+
```
141+
* If both tests pass, your code doesn't have any obvious errors!
142+
143+
######Option 2: Put your hero in a mini-battle######
144+
145+
* On the command line, navigate to your hero directory.
146+
* After making sure you have Node installed, type in the following command:
147+
```
148+
node test_your_hero_code.js
149+
```
150+
* This will run and print out the results of a "mini-game" of only 15 turns which takes place on a 5x5 game board against a single enemy hero.
151+
* The command line will output what the board looks like at each turn, and will output the moves your hero tried to make each turn.
152+
* Your hero will be denoted by the code "H00", the enemy hero will be denoted by the code "H01"
153+

package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "hero-starter",
3+
"version": "0.0.0",
4+
"description": "![](https://raw.githubusercontent.com/JavascriptBattle/javascript-battle-website/master/public/img/black-knight.png)",
5+
"main": "helpers.js",
6+
"scripts": {
7+
"test": "npm run test-hero-brain",
8+
"test-hero-brain": "mocha -R spec ./test/spec/HeroBrainSpec.js"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/gjtrowbridge/hero-starter.git"
13+
},
14+
"author": "",
15+
"license": "ISC",
16+
"bugs": {
17+
"url": "https://github.com/gjtrowbridge/hero-starter/issues"
18+
},
19+
"homepage": "https://github.com/gjtrowbridge/hero-starter",
20+
"devDependencies": {
21+
"chai": "^1.9.2",
22+
"mocha": "^1.21.4"
23+
}
24+
}

test/spec/HeroBrainSpec.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var chai = require('chai');
2+
var should = chai.should();
3+
var expect = chai.expect;
4+
5+
describe('Hero file', function () {
6+
'use strict';
7+
var move;
8+
9+
beforeEach(function() {
10+
move = require('../../hero.js');
11+
});
12+
13+
it('exists and exports a move function', function () {
14+
move.should.be.a('function');
15+
});
16+
17+
18+
});
19+
describe('Helper file', function () {
20+
'use strict';
21+
var helpers;
22+
23+
beforeEach(function() {
24+
helpers = require('../../helpers.js');
25+
});
26+
27+
it('exists and exports a helper object', function () {
28+
helpers.should.be.a('object');
29+
});
30+
31+
});

0 commit comments

Comments
 (0)