Skip to content
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

feat: added jest fail test utilities #13

Merged
merged 10 commits into from
Jun 18, 2022
10 changes: 3 additions & 7 deletions apps/demo-api/src/app/function/profile/profile.function.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { profileIdentity, SetProfileUsernameParams, UpdateProfileParams } from '
import { DemoApiFunctionContextFixture, demoApiFunctionContextFactory, demoAuthorizedUserContext } from '../../../test/fixture';
import { describeCloudFunctionTest } from '@dereekb/firebase-server/test';
import { firestoreModelKey, onCallTypedModelParams } from '@dereekb/firebase';
import { expectFail, itShouldFail } from '@dereekb/util/test';

/**
* NOTES:
Expand Down Expand Up @@ -42,7 +43,7 @@ demoApiFunctionContextFactory((f: DemoApiFunctionContextFixture) => {

// second user
demoAuthorizedUserContext({ f }, (u2) => {
it('should fail if the username is already taken.', async () => {
itShouldFail('if the username is already taken.', async () => {
const fn = f.fnWrapper.wrapV1CloudFunction(profileSetUsername(f.nestAppPromiseGetter));

const params: SetProfileUsernameParams = {
Expand All @@ -53,12 +54,7 @@ demoApiFunctionContextFactory((f: DemoApiFunctionContextFixture) => {
await fn(params, await u.makeContextOptions());

// attempt to take with user 2
try {
await fn(params, await u2.makeContextOptions());
fail();
} catch (e) {
expect(e).toBeDefined();
}
await expectFail(async () => fn(params, await u2.makeContextOptions()));
});
});
});
Expand Down
Loading