Commit 6fc8f84a authored by Ermolaev Timur's avatar Ermolaev Timur

#42 написал фикстуру для проектов

parent 36e04fb1
......@@ -15,10 +15,10 @@ const loadFixtures = async () => {
.then(async () => {
const repositoryTask = myDataSource.getRepository(Task);
await repositoryTask.delete({});
const repositoryProject = myDataSource.getRepository(Project);
await repositoryProject.delete({})
const repositoryUser = myDataSource.getRepository(User);
await repositoryUser.delete({});
const repositoryProject = myDataSource.getRepository(Project);
await repositoryProject.delete({});
console.log('========================== ' + '\n' + 'Data Source has been cleared!' +'\n' + '==========================')
const userRoles = [{role: UserRole.DIRECTOR}, {role: UserRole.SUPERUSER}, {role: UserRole.USER}, {role: UserRole.USER}];
......@@ -39,13 +39,13 @@ const loadFixtures = async () => {
await user.save();
users.push(user)
}
const tasks = []
const tasks:Task[] = []
type taskFinishType = "opened" | "done" |"failed";
type priorityType = "A" | "B" |"C";
const priorities:priorityType[] = ["A", "B" , "C"]
const accomplish:taskFinishType[] = ["opened", "done" , "failed"]
for (let i = 0; i < 15; i++) {
if (i <= 10) {
for (let i = 0; i < 20; i++) {
if (i <= 15) {
const newTask = new Task();
newTask.title = `Buy ${faker.commerce.productName()}`;
newTask.description = faker.random.words(4);
......@@ -71,6 +71,15 @@ const loadFixtures = async () => {
tasks.push(newTask)
}
}
for (let i = 0; i < 5; i++) {
const newProject = new Project();
newProject.title = `Project ${faker.random.words(1)}`;
newProject.color = faker.random.words(4);
newProject.admin = faker.helpers.arrayElement(users);
newProject.workers = faker.helpers.arrayElements(users, randomIntFromInterval(1, 3));
newProject.tasks = faker.helpers.arrayElements(tasks, randomIntFromInterval(0, 19));
await newProject.save();
}
console.log('========================== ' + '\n' + 'Fixtures done!' +'\n' + '==========================')
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment