From 9aeacc1052d30cbd0ae9722d137d8e2efc32fdf6 Mon Sep 17 00:00:00 2001 From: Clinton Blackburn Date: Fri, 5 Jan 2024 14:16:11 -0800 Subject: [PATCH] fix(resource): Updated mock authenticator for e2e tests We no longer mock Firebase, but use the mockAuthentication method. --- package.json | 2 +- .../files/ts/__name__.e2e.__specFileSuffix__.ts | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index fb413e267..22f863bc5 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "git", "url": "https://github.com/voriteam/nest-schematics.git" }, - "version": "1.0.2", + "version": "1.0.3", "description": "Nest - modern, fast, powerful node.js web framework (@schematics)", "main": "dist/index.js", "files": [ diff --git a/src/lib/resource/files/ts/__name__.e2e.__specFileSuffix__.ts b/src/lib/resource/files/ts/__name__.e2e.__specFileSuffix__.ts index 7a9730e2b..358dc3e7a 100644 --- a/src/lib/resource/files/ts/__name__.e2e.__specFileSuffix__.ts +++ b/src/lib/resource/files/ts/__name__.e2e.__specFileSuffix__.ts @@ -1,5 +1,4 @@ -import { faker } from '@faker-js/faker'; -import { INestApplication, Injectable } from '@nestjs/common'; +import { INestApplication } from '@nestjs/common'; import { instanceToPlain } from 'class-transformer'; import { orderBy, times } from 'lodash'; import request from 'supertest'; @@ -12,7 +11,6 @@ import { APIBannerUser } from '@vori/types/User'; import { makeAndSaveBanner } from '@vori/utils/VoriRandom/Banner.random'; import { configureApp } from '@vori/nest/bootstrap'; -import { FirebaseAuthStrategy } from '@vori/nest/libs/auth/firebase-auth.strategy'; import { createAnnotatedUser, createE2ETestingModule, @@ -37,15 +35,6 @@ describe('/v1/<%= dasherize(name) %>', () => { let user: APIBannerUser | undefined; let <%= lowercased(name) %>Service: <%= classify(name) %>Service; - @Injectable() - class MockFirebaseAuthStrategy extends FirebaseAuthStrategy { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - async validate(token): Promise { - return user; - } - } - beforeAll(async () => { mockTemporalSetupAndShutdown(); @@ -53,8 +42,7 @@ describe('/v1/<%= dasherize(name) %>', () => { // TODO Remember to import <%= classify(name) %>Module into AppModule imports: [AppModule], }) - .overrideProvider(FirebaseAuthStrategy) - .useClass(MockFirebaseAuthStrategy) + .mockAuthentication(() => user) .compile(); app = moduleRef.createNestApplication();