Skip to content

Commit

Permalink
chore: add testing (#94)
Browse files Browse the repository at this point in the history
* chore: add testing

Co-authored-by: Oliver Eyton-Williams <[email protected]>
  • Loading branch information
Nicholas Carrigan (he/him) and ojeytonwilliams authored Jan 14, 2022
1 parent ca9557e commit 4bade20
Show file tree
Hide file tree
Showing 57 changed files with 8,377 additions and 2,204 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Node.js CI
on:
pull_request:
branches:
- master

jobs:
ci:
name: Lint / Build / Test
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- name: Checkout Source Files
uses: actions/checkout@v2

- name: Use Node.js v${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Start database
uses: supercharge/[email protected]

- name: Install Dependencies
run: npm ci

- name: Run Tests
run: npm run test-local-or-ci
2 changes: 1 addition & 1 deletion american-british-translator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "server.js",
"scripts": {
"start": "nodemon server.js",
"test": "mocha --timeout 5000 --require @babel/register --recursive --ui tdd tests/"
"test": "mocha --timeout 5000 --require @babel/register --recursive --exit --ui tdd tests/"
},
"dependencies": {
"@babel/core": "^7.11.6",
Expand Down
2 changes: 1 addition & 1 deletion anonymous-message-board/sample.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PORT=
DB_URI=
DB_URI="mongodb://localhost:27017/message-board"
# NODE_ENV=test
10 changes: 2 additions & 8 deletions anonymous-message-board/tests/2_functional-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ suite('Functional Tests', function() {
chai.request(server)
.get('/api/threads/fcc-test')
.end(function(err, res) {
testId = res.body[0]._id;
testId2 = res.body[1]._id;
assert.equal(res.status, 200);
assert.isArray(res.body);
assert.isBelow(res.body.length, 11);
Expand All @@ -56,12 +58,8 @@ suite('Functional Tests', function() {
assert.property(res.body[0], 'bumped_on');
assert.property(res.body[0], 'text');
assert.property(res.body[0], 'replies');
assert.property(res.body[0], 'reported');
assert.property(res.body[0], 'delete_password');
assert.isArray(res.body[0].replies);
assert.isBelow(res.body[0].replies.length, 4);
testId = res.body[0]._id;
testId2 = res.body[1]._id;
done();
});
});
Expand Down Expand Up @@ -141,11 +139,7 @@ suite('Functional Tests', function() {
assert.property(res.body, 'bumped_on');
assert.property(res.body, 'text');
assert.property(res.body, 'replies');
assert.property(res.body, 'delete_password');
assert.property(res.body, 'reported');
assert.isArray(res.body.replies);
assert.property(res.body.replies[0], 'delete_password');
assert.property(res.body.replies[0], 'reported');
assert.equal(res.body.replies[0].text, 'a reply'+testText);
done();
});
Expand Down
2 changes: 1 addition & 1 deletion build-a-pinterest-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "server.js",
"scripts": {
"start": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "wait-port -t 10000 3000"
},
"keywords": [],
"author": "",
Expand Down
6 changes: 3 additions & 3 deletions build-a-pinterest-clone/sample.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GITHUB_KEY=
GITHUB_SECRET=
DB_URI=
GITHUB_KEY="foo"
GITHUB_SECRET="bar"
DB_URI="mongodb://localhost:27017/pinterest"
APP_URL=
NODE_ENV=
2 changes: 1 addition & 1 deletion chart-the-stock-market/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "wait-port -t 10000 3000"
},
"author": "",
"license": "ISC",
Expand Down
2 changes: 1 addition & 1 deletion exercise-tracker/models/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Users = new Schema({
type: String,
required: true,
unique: true,
maxlength: [20, 'username too long']
maxlength: [30, 'username too long']
}
});

Expand Down
Loading

0 comments on commit 4bade20

Please sign in to comment.