-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Massive overhauls. Adding Travis C.I. build. FINALLY have testing!!! …
…Added linting rules to keep the project clean.
- Loading branch information
1 parent
92d7ad5
commit 266c10d
Showing
16 changed files
with
1,392 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"extends": "google", | ||
"env": { | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
}, | ||
"rules": { | ||
"comma-dangle": [2, "never"], | ||
"max-len": [2, { | ||
"code": 100, | ||
"tabWidth": 2 | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- "4" | ||
- "5" | ||
- "6" | ||
- "7" | ||
script: | ||
- npm test | ||
- npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
'use strict'; | ||
|
||
const request = require('supertest'); | ||
|
||
const { | ||
app | ||
} = require('./server'); | ||
|
||
let mockUser = { | ||
firstName: 'Joe', | ||
lastName: 'Schmo', | ||
email: 'joe@mailinator.com' | ||
}; | ||
|
||
let mockCars = [ | ||
'rsx', | ||
'tsx', | ||
'civic', | ||
'integra' | ||
]; | ||
|
||
describe('Test Multipart Form Single Field Submissions', function() { | ||
it('submit multipart user data with POST', function(done) { | ||
request(app) | ||
.post('/fields/user') | ||
.field('firstName', mockUser.firstName) | ||
.field('lastName', mockUser.lastName) | ||
.field('email', mockUser.email) | ||
.expect('Content-Type', /json/) | ||
.expect(200, { | ||
firstName: mockUser.firstName, | ||
lastName: mockUser.lastName, | ||
email: mockUser.email | ||
}, done); | ||
}); | ||
|
||
it('submit multipart user data with PUT', function(done) { | ||
request(app) | ||
.post('/fields/user') | ||
.field('firstName', mockUser.firstName) | ||
.field('lastName', mockUser.lastName) | ||
.field('email', mockUser.email) | ||
.expect('Content-Type', /json/) | ||
.expect(200, { | ||
firstName: mockUser.firstName, | ||
lastName: mockUser.lastName, | ||
email: mockUser.email | ||
}, done); | ||
}); | ||
|
||
it('fail when user data submitted without multipart', function(done) { | ||
request(app) | ||
.post('/fields/user') | ||
.send(mockUser) | ||
.expect(400) | ||
.end(done); | ||
}); | ||
|
||
it('fail when user data not submitted', function(done) { | ||
request(app) | ||
.post('/fields/user') | ||
.expect(400) | ||
.end(done); | ||
}); | ||
}); | ||
|
||
describe('Test Multipart Form Array Field Submissions', function() { | ||
it('submit array of data with POST', function(done) { | ||
let req = request(app).post('/fields/array'); | ||
|
||
for (let i = 0; i < mockCars.length; i++) { | ||
req.field('testField', mockCars[i]); | ||
} | ||
|
||
req | ||
.expect(200) | ||
.end(function(err, res) { | ||
if (err) | ||
return done(err); | ||
|
||
let responseMatchesRequest = res.body.join(',') === mockCars.join(','); | ||
|
||
done(responseMatchesRequest ? null : 'Data was returned as expected.'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.