-
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.
Add magazines to weekly debrief (#66)
* Implemented community board models - implemented Flyer and Organization models for community board feature - modified User model - updated typescript version to 4.0.5 to resolve es lint issue * Implemented weekly debrief magazines - added magazines to weekly debrief feature - updated user and weekly debrief models to allow tracking of read magazines - updated logic in user and weekly debrief controllers to enable reading of magazines * Revert package.json changes - reverted package.json changes back to the original file - added additional rules to eslintrc to suppress es lint warnings * Create jest testing for magazines - added jest test cases for magazines * Implement jest testing for User - implemented unit testing for UserRepo - indirectly test Weekly Debrief with User unit tests * Update gitignore - updated gitignore file to include secrets folder
- Loading branch information
1 parent
bf2774c
commit 6505521
Showing
11 changed files
with
486 additions
and
0 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
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ nohup.out | |
*src/certificates* | ||
Makefile | ||
start.sh | ||
*secrets* | ||
|
||
# ignore database dumps | ||
dump/ |
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* eslint-disable no-underscore-dangle */ | ||
import { faker } from '@faker-js/faker'; | ||
import { _ } from 'underscore'; | ||
import PublicationFactory from './PublicationFactory'; | ||
import { Magazine } from '../../entities/Magazine'; | ||
import FactoryUtils from './FactoryUtils'; | ||
|
||
class MagazineFactory { | ||
public static async create(n: number): Promise<Magazine[]> { | ||
/** | ||
* Returns a list of n number of random Magazine objects | ||
*/ | ||
return Promise.all(FactoryUtils.create(n, MagazineFactory.fake)); | ||
} | ||
|
||
public static async createSpecific( | ||
n: number, | ||
newMappings: { [key: string]: any }, | ||
): Promise<Magazine[]> { | ||
/** | ||
* Returns a list of n number of random Magazine objects with specified | ||
* field values in new Mappings | ||
*/ | ||
const arr = await MagazineFactory.create(n); | ||
return arr.map((x) => { | ||
const newDoc = x; | ||
Object.entries(newMappings).forEach(([k, v]) => { | ||
newDoc[k] = v; | ||
}); | ||
return newDoc; | ||
}); | ||
} | ||
|
||
public static async fake(): Promise<Magazine> { | ||
/** | ||
* Returns a Magazine with random values in its instance variables | ||
*/ | ||
const fakeMagazine = new Magazine(); | ||
const examplePublication = await PublicationFactory.getRandomPublication(); | ||
|
||
fakeMagazine.date = faker.date.past(); | ||
fakeMagazine.semester = _.sample(['FA22', 'SP23']); | ||
fakeMagazine.pdfURL = faker.image.cats(); | ||
fakeMagazine.publication = examplePublication; | ||
fakeMagazine.publicationSlug = examplePublication.slug; | ||
fakeMagazine.shoutouts = _.random(0, 50); | ||
fakeMagazine.title = faker.commerce.productDescription(); | ||
fakeMagazine.nsfw = _.sample([true, false]); | ||
fakeMagazine.isFeatured = _.sample([true, false]); | ||
fakeMagazine.trendiness = 0; | ||
fakeMagazine.isFiltered = _.sample([true, false]); | ||
|
||
return fakeMagazine; | ||
} | ||
} | ||
export default MagazineFactory; |
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,55 @@ | ||
/* eslint-disable no-underscore-dangle */ | ||
import { faker } from '@faker-js/faker'; | ||
import { _ } from 'underscore'; | ||
import { User } from '../../entities/User'; | ||
import FactoryUtils from './FactoryUtils'; | ||
|
||
class UserFactory { | ||
public static async create(n: number): Promise<User[]> { | ||
/** | ||
* Returns a list of n number of random User objects | ||
* | ||
* @param n The number of desired random User objects | ||
* @returns A Promise of the list of n number of random User objects | ||
*/ | ||
return Promise.all(FactoryUtils.create(n, UserFactory.fake)); | ||
} | ||
|
||
public static async createSpecific( | ||
n: number, | ||
newMappings: { [key: string]: any }, | ||
): Promise<User[]> { | ||
/** | ||
* Returns a list of n number of random User objects with specified | ||
* fields values in newMappings | ||
* | ||
* @param n The number of desired random User objects | ||
* @param newMappings The specified values for User parameters [key] | ||
* @returns A Promise of the list of n number of random User objects | ||
*/ | ||
const arr = await UserFactory.create(n); | ||
return arr.map((x) => { | ||
const newDoc = x; | ||
Object.entries(newMappings).forEach(([k, v]) => { | ||
newDoc[k] = v; | ||
}); | ||
return newDoc; | ||
}); | ||
} | ||
|
||
public static async fake(): Promise<User> { | ||
/** | ||
* Returns a User with random values in its instance variables | ||
* | ||
* @returns The User object with random values in its instance variables | ||
*/ | ||
const fakeUser = new User(); | ||
|
||
fakeUser.deviceToken = faker.datatype.string(); | ||
fakeUser.deviceType = _.sample(['IOS', 'ANDROID']); | ||
fakeUser.uuid = faker.datatype.uuid(); | ||
|
||
return fakeUser; | ||
} | ||
} | ||
export default UserFactory; |
Oops, something went wrong.