forked from b00tc4mp/isdi-parttime-202309
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try unsucessfully to modify vite config to simplify relative paths fo…
…r shared folder b00tc4mp#430
- Loading branch information
Showing
10 changed files
with
182 additions
and
25 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
70 changes: 70 additions & 0 deletions
70
staff/judy-grayland/project/api/logic/createActivity.spec.js
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,70 @@ | ||
import dotenv from 'dotenv' | ||
import mongoose from 'mongoose' | ||
import { expect } from 'chai' | ||
import random from './helpers/random.js' | ||
import { errors } from 'shared' | ||
const { DuplicityError, ContentError } = errors | ||
|
||
import { Activity } from '../data/models.js' | ||
import createActivity from './createActivity.js' | ||
|
||
dotenv.config() | ||
|
||
describe('createActivity', () => { | ||
before(() => mongoose.connect(process.env.MONGODB_URL_TEST)) | ||
beforeEach(() => Activity.deleteMany()) | ||
|
||
// HAPPY path | ||
it('succeeds on new activity begin correctly created', () => { | ||
const title = random.title() | ||
const description = random.description() | ||
const image = random.image() | ||
const link = random.link() | ||
|
||
return createActivity(title, description, image, link).then((value) => { | ||
expect(value).to.be.undefined | ||
return Activity.findOne({ title: title }).then((activity) => { | ||
expect(activity.description).to.equal(description) | ||
expect(activity.image).to.equal(image) | ||
expect(activity.link).to.equal(link) | ||
}) | ||
}) | ||
}) | ||
|
||
it('fails on already existing activity', () => { | ||
const title = random.title() | ||
const description = random.description() | ||
const image = random.image() | ||
const link = random.link() | ||
|
||
return Activity.create({ title, description, image, link }).then( | ||
(activity) => { | ||
return createActivity(title, description, image, link) | ||
.then(() => { | ||
throw new Error('should not reach this point') | ||
}) | ||
.catch((error) => { | ||
expect(error).to.be.instanceOf(DuplicityError) | ||
expect(error.message).to.equal('activity already exists') | ||
}) | ||
} | ||
) | ||
}) | ||
|
||
it('fails on empty field', () => { | ||
const title = random.title() | ||
const description = random.description() | ||
const image = '' | ||
const link = random.link() | ||
|
||
// our validate.js catches the error and throws a ContentError because the image field is empty. We don't need to put a separate if logic that throws an error if one of the parameters(title, descrip, image or link) is missing. If we add that, it doesn't catch the error. | ||
try { | ||
return createActivity(title, description, image, link) | ||
} catch (error) { | ||
expect(error).to.be.instanceOf(ContentError) | ||
expect(error.message).to.equal('image is empty') | ||
} | ||
}) | ||
|
||
after(() => mongoose.disconnect()) | ||
}) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import registerUser from './registerUser' | ||
import authenticateUser from './authenticateUser' | ||
import logoutUser from './logoutUser' | ||
|
||
const logic = { | ||
registerUser, | ||
authenticateUser, | ||
logoutUser, | ||
} | ||
|
||
export default logic |
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,8 @@ | ||
import context from './context' | ||
|
||
function logoutUser() { | ||
context.sessionUserId = null | ||
context.token = null | ||
} | ||
|
||
export default logoutUser |
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