Skip to content

Commit e4cf7cc

Browse files
testing working
1 parent 6a2a3f7 commit e4cf7cc

File tree

4 files changed

+16
-31
lines changed

4 files changed

+16
-31
lines changed

app/auth/auth.router.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,13 @@ authRouter.post('/refresh', jwtPassportMiddleware, (request, response) => {
4949
});
5050
});
5151

52-
<<<<<<< HEAD
53-
authRouter.post('/logout', localPassportMiddleware, (req, res) => {
54-
res.header('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
55-
}
56-
module.exports = {
57-
authRouter
58-
});
59-
60-
=======
6152
authRouter.post('/logout', (req, res) => {
6253

6354
res.header('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
6455
res.json({
6556

6657
})
6758
});
68-
>>>>>>> 7867560ecc9fefea91206abd0e5963e313dce6b3
6959
module.exports = {
7060
authRouter
7161
};

app/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ passport.use(jwtStrategy);
3737
app.use(morgan('combined')); //allows morgan to intercept and alog all http requests to console
3838
app.use(express.json()); // Required so AJAX request JSON data payload can be parsed and saved into request.body
3939
app.use(express.static('./public'));
40-
app.use(express.urlencoded());
40+
app.use(express.urlencoded({ extended: true }));
4141

4242
//ROUTER SETUP
4343
app.use('/api/auth', authRouter);

app/workout/workout.model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const mongoose = require("mongoose");
22
const Joi = require("joi");
3-
const dateFns = require('date-fns');
3+
44

55

66
const workoutSchema = new mongoose.Schema({

test/workout.test.js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,29 +109,27 @@ describe('Integration tests for: /api/home', function() {
109109
.get('/api/home')
110110
.set('Authorization', `Bearer ${jwtToken}`)
111111
.then(res => {
112+
console.log("The body:",res.body[0].sets);
112113
expect(res).to.have.status(HTTP_STATUS_CODES.OK);
113114
expect(res).to.be.json;
114115
expect(res.body).to.be.a('array');
115116
expect(res.body).to.have.lengthOf.at.least(1);
116-
console.log("The body:",res.body[0].sets);
117-
const workout = res.body[0].sets;
118117

119-
expect(workout).to.include.keys('user', 'exercise', 'set', 'reps');
120-
// expect(workout.user).to.be.a('object');
121-
// expect(workout.user).to.include.keys('name', 'email', 'username');
122-
// expect(workout.user).to.nested.include({
123-
// id: testUser.id,
124-
// username: testUser.username,
125-
// email: testUser.email,
126-
// name: testUser.name
127-
// });
118+
const workout = res.body[0];
119+
console.log("User workout:", workout)
120+
121+
expect(workout).to.include.keys('user','sets');
122+
expect(workout.sets).to.include.keys( 'exercise', 'set', 'reps')
123+
expect(workout.user).to.be.a('string');
124+
128125
});
129126
});
130127

131128
it('Should return a specific workout', function() {
132129
let foundWorkout;
133130
return Workout.find()
134131
.then(workouts => {
132+
135133
expect(workouts).to.be.a('array');
136134
expect(workouts).to.have.lengthOf.at.least(1);
137135
foundWorkout = workouts[0];
@@ -141,10 +139,12 @@ describe('Integration tests for: /api/home', function() {
141139
.set('Authorization', `Bearer ${jwtToken}`);
142140
})
143141
.then(res => {
142+
144143
expect(res).to.have.status(HTTP_STATUS_CODES.OK);
145144
expect(res).to.be.json;
146-
expect(res.body).to.be.a('object');
147-
expect(res.body).to.include.keys('user', 'exercise', 'set', 'reps');
145+
// expect(res.body).to.be.a('object');
146+
expect(res.body).to.include.keys('user','sets');
147+
expect(res.body.sets).to.include.keys('exercise', 'set', 'reps');
148148

149149
});
150150
});
@@ -183,11 +183,6 @@ describe('Integration tests for: /api/home', function() {
183183
}
184184

185185
function createFakerWorkout() {
186-
return {
187-
exercise: faker.lorem.word(),
188-
set: faker.random.number(),
189-
reps: faker.random.number(),
190-
191-
};
186+
return {sets:{exercise: faker.lorem.word(),set: faker.random.number(),reps: faker.random.number()}};
192187
}
193188
});

0 commit comments

Comments
 (0)