Skip to content

Adds testing for the organization avatar url #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: start
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions exercises/hooks/__test__/org.spec.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
const Project = require('../project')
const Org = require('../org')
const mongoose = require('mongoose')
const Project = require('../project');
const Org = require('../org');
const mongoose = require('mongoose');
const cdnUrl = 'https://cdn.adminapp.com';

describe('Org model', () => {
test('removes projects when org is remove', async () => {
const org = await Org.create({name: 'org'})
test('removes projects when org is removed', async () => {
const org = await Org.create({ name: 'org' });
await Project.create([
{name: 'project1', org: org.id},
{name: 'project', org: org.id}
])

await org.remove()
const matchedProjects = await Project.find({org: org._id}).exec()
expect(matchedProjects).toHaveLength(0)
})
})
{ name: 'project1', org: org.id },
{ name: 'project', org: org.id }
]);

await org.remove();
const matchedProjects = await Project.find({ org: org._id }).exec();
expect(matchedProjects).toHaveLength(0);
});

test('has the avatar virtual getter', async () => {
const org = await Org.create({ name: 'org' });
expect(org.avatar).toBe(`${cdnUrl}/${org._id}`);
});
});