@nestjs/typeorm#getRepositoryToken TypeScript Examples

The following examples show how to use @nestjs/typeorm#getRepositoryToken. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: app.controller.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('AppController', () => {
  let appController: AppController;
  beforeEach(async () => {
    const app: TestingModule = await Test.createTestingModule({
      imports: [
        BullModule.forRoot({
          name: 'test',
          processors: [jest.fn()],
        }),
      ],
      controllers: [AppController],
      providers: [
        AppService,
        LicenseService,
        { provide: getRepositoryToken(License), useClass: mockRepository },
        { provide: getQueueToken('scan-queue'), useValue: { add: jest.fn } },
      ],
    }).compile();

    appController = app.get<AppController>(AppController);
  });

  describe('root', () => {
    it('should instantiate', () => {
      expect(appController).toBeDefined();
    });

    it('should return a result', () => {
      expect(appController.appStatus()).toBeDefined();
    });
  });
});
Example #2
Source File: sites.controller.spec.ts    From aqualink-app with MIT License 6 votes vote down vote up
describe('Sites Controller', () => {
  let controller: SitesController;
  let service: SitesService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      // Mock version of SiteRepository - it will inject the `useValue` as the service in the controller, so you can add
      // mock implementations there.
      providers: [
        SitesService,
        { provide: getRepositoryToken(Site), useClass: Repository },
        { provide: getRepositoryToken(DailyData), useClass: Repository },
        { provide: getRepositoryToken(Region), useClass: Repository },
        { provide: getRepositoryToken(ExclusionDates), useClass: Repository },
        {
          provide: getRepositoryToken(HistoricalMonthlyMean),
          useClass: Repository,
        },
        { provide: getRepositoryToken(User), useClass: Repository },
        { provide: getRepositoryToken(SiteApplication), useClass: Repository },
        { provide: getRepositoryToken(Sources), useClass: Repository },
        { provide: getRepositoryToken(LatestData), useClass: Repository },
      ],
      // You could also provide it the real SiteRepository, but then you'll also have to take care of providing *its*
      // dependencies too (e.g. with an `imports` block.
      // providers: [SiteRepository],
      controllers: [SitesController],
    }).compile();

    service = module.get<SitesService>(SitesService);
    controller = module.get<SitesController>(SitesController);
  });

  it('should be defined', () => {
    expect(controller).toBeDefined();
    expect(service).toBeDefined();
  });
});
Example #3
Source File: vulnerability-status-deployment-type.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('VulnerabilityStatusDeploymentTypeService', () => {
  let service: VulnerabilityStatusDeploymentTypeService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        VulnerabilityStatusDeploymentTypeService,
        {
          provide: getRepositoryToken(VulnerabilityStatusDeploymentType),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<VulnerabilityStatusDeploymentTypeService>(VulnerabilityStatusDeploymentTypeService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #4
Source File: user.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('UserService', () => {
  let service: UserService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      imports: [
        PassportModule,
        JwtModule.register({
          secret: jwtConstants.secret,
          signOptions: { expiresIn: '3600s' },
        }),
      ],
      providers: [
        LocalStrategy,
        JwtStrategy,
        UserService,
        LdapService,
        { provide: getRepositoryToken(User), useClass: mockRepository },
      ],
    }).compile();

    service = module.get<UserService>(UserService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #5
Source File: tooltips.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('ToolTipService', () => {
  let service: ToolTip;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        ToolTip,
        {
          provide: getRepositoryToken(ToolTip),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<ToolTip>(ToolTip);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #6
Source File: system-configuration.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('SystemConfigurationService', () => {
  let service: SystemConfigurationService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        SystemConfigurationService,
        {
          provide: getRepositoryToken(SystemConfiguration),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<SystemConfigurationService>(SystemConfigurationService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #7
Source File: security-scan-result-item-status-type.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('SecurityScanResultItemStatusTypeService', () => {
  let service: SecurityScanResultItemStatusTypeService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        SecurityScanResultItemStatusTypeService,
        {
          provide: getRepositoryToken(SecurityScanResultItemStatusType),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<SecurityScanResultItemStatusTypeService>(SecurityScanResultItemStatusTypeService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #8
Source File: security-scan-result-item.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('SecurityScanResultItemService', () => {
  let service: SecurityScanResultItemService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        SecurityScanResultItemService,
        {
          provide: getRepositoryToken(SecurityScanResultItem),
          useClass: mockRepository,
        },
        {
          provide: 'VulnerabilityStatusDeploymentTypeService',
          useValue: {},
        },
      ],
    }).compile();

    service = module.get<SecurityScanResultItemService>(SecurityScanResultItemService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #9
Source File: security-scan-result.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('SecurityScanResultService', () => {
  let service: SecurityScanResultService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        SecurityScanResultService,
        {
          provide: getRepositoryToken(SecurityScanResult),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<SecurityScanResultService>(SecurityScanResultService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #10
Source File: scan-log.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('ScanLogService', () => {
  let service: ScanLogService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        ScanLogService,
        {
          provide: getRepositoryToken(ScanLog),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<ScanLog>(ScanLogService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #11
Source File: scan.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('ScanService', () => {
  let service: ScanService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        ScanService,
        { provide: 'LicenseScanResultService', useClass: jest.fn() },
        { provide: 'SecurityScanResultService', useClass: jest.fn() },
        { provide: 'LicenseScanResultItemService', useClass: jest.fn() },
        { provide: 'SecurityScanResultItemService', useClass: jest.fn() },
        { provide: 'BomManualLicenseService', useClass: jest.fn() },
        { provide: 'BomLicenseExceptionService', useClass: jest.fn() },
        { provide: 'BomSecurityExceptionService', useClass: jest.fn() },
        { provide: 'ProjectService', useClass: jest.fn() },
        {
          provide: getRepositoryToken(Scan),
          useClass: mockRepository,
        },
        { provide: getQueueToken('scan-queue'), useValue: { add: jest.fn } },
      ],
    }).compile();

    service = module.get<ScanService>(ScanService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #12
Source File: project-status-type.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('SecurityScanResultItemStatusTypeService', () => {
  let service: ProjectStatusTypeService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        ProjectStatusTypeService,
        {
          provide: getRepositoryToken(ProjectStatusType),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<ProjectStatusTypeService>(ProjectStatusTypeService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #13
Source File: project-scan-status-type.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('SecurityScanResultItemStatusTypeService', () => {
  let service: ProjectScanStatusTypeService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        ProjectScanStatusTypeService,
        {
          provide: getRepositoryToken(ProjectScanStatusType),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<ProjectScanStatusTypeService>(ProjectScanStatusTypeService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #14
Source File: project-notes.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('ProjectNotesService', () => {
  let service: ProjectNotesService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        ProjectNotesService,
        {
          provide: getRepositoryToken(ProjectNote),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<ProjectNotesService>(ProjectNotesService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #15
Source File: project-development-type.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('ProjectDevelopmentTypeService', () => {
  let service: ProjectDevelopmentTypeService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        ProjectDevelopmentTypeService,
        {
          provide: getRepositoryToken(ProjectDevelopmentType),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<ProjectDevelopmentTypeService>(ProjectDevelopmentTypeService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #16
Source File: project-attribution.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('ProjectAttributionService', () => {
  let service: ProjectAttributionService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        ProjectAttributionService,
        {
          provide: getRepositoryToken(ProjectAttribution),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<ProjectAttributionService>(ProjectAttributionService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #17
Source File: package-manager.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('PackageManagerService', () => {
  let service: PackageManagerService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        PackageManagerService,
        {
          provide: getRepositoryToken(PackageManager),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<PackageManagerService>(PackageManagerService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #18
Source File: log.service.spec.ts    From 42_checkIn with GNU General Public License v3.0 6 votes vote down vote up
describe('LogService', () => {
  let service: LogService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        LogService,
        {
          provide: getRepositoryToken(Log),
          useValue: mockRepository,
        },
      ],
    }).compile();

    service = module.get<LogService>(LogService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
  describe('getUserLog', () => {
    it('should return a log', async () => {
      const log = await service.getUserLog('ryukim');
      expect(log).toBeInstanceOf(Log);
    });
  });
});
Example #19
Source File: obligation.controller.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('Obligation Controller', () => {
  let controller: ObligationController;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      controllers: [ObligationController],
      providers: [
        ObligationService,
        { provide: 'LicenseService', useClass: jest.fn() },
        { provide: getRepositoryToken(Obligation), useClass: mockRepository },
      ],
    }).compile();

    controller = module.get<ObligationController>(ObligationController);
  });

  it('should be defined', () => {
    expect(controller).toBeDefined();
  });
});
Example #20
Source File: bom-license-exception.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('BomLicenseExceptionService', () => {
  let service: BomLicenseExceptionService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        BomLicenseExceptionService,
        {
          provide: getRepositoryToken(BomLicenseException),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<BomLicenseExceptionService>(BomLicenseExceptionService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #21
Source File: bom-manual-license.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('BomLicenseExceptionService', () => {
  let service: BomManualLicenseService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        BomManualLicenseService,
        {
          provide: 'LicenseStatusDeploymentTypeService',
          useClass: jest.fn(),
        },
        {
          provide: getRepositoryToken(BomManualLicense),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<BomManualLicenseService>(BomManualLicenseService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #22
Source File: bom-security-exception.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('BomSecurityExceptionService', () => {
  let service: BomSecurityExceptionService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        BomSecurityExceptionService,
        {
          provide: getRepositoryToken(BomSecurityException),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<BomSecurityExceptionService>(BomSecurityExceptionService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #23
Source File: clearly-defined.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('ProjectDevelopmentTypeService', () => {
  let service: ClearlyDefinedService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        ClearlyDefinedService,
        {
          provide: getRepositoryToken(DeploymentType),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<ClearlyDefinedService>(ClearlyDefinedService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #24
Source File: deployment-type.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('ProjectDevelopmentTypeService', () => {
  let service: DeploymentTypeService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        DeploymentTypeService,
        {
          provide: getRepositoryToken(DeploymentType),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<DeploymentTypeService>(DeploymentTypeService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #25
Source File: license.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('LicenseService', () => {
  let service: LicenseService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [LicenseService, { provide: getRepositoryToken(License), useValue: mockRepository }],
    }).compile();

    service = module.get<LicenseService>(LicenseService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });

  it('gets an spdx identifier from a license expression', () => {
    const actual = LicenseService.getSpdxId('GNU General Public License Version 2');
    const expected = 'GPL-2.0-only';
    expect(actual).toEqual(expected);
  });

  it('fuzzy matches from existing licenses', async done => {
    // Return mock license results

    mockRepository.find.mockReturnValueOnce([
      { name: 'XXXX', code: 'xxx' },
      { name: 'Common Public License 1.0', code: 'CPL-1.0' },
      { name: 'Common Public', code: 'not-CPL-1.0' },
    ]);
    const actual = await service.fuzzyMatchLicense('Common Public License Version 1.0');
    const expected = 'CPL-1.0';
    expect(actual.code).toEqual(expected);

    done();
  });
});
Example #26
Source File: license-scan-result.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('LicenseScanResultItemService', () => {
  let service: LicenseScanResultService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        LicenseScanResultService,
        {
          provide: getRepositoryToken(LicenseScanResult),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<LicenseScanResultService>(LicenseScanResultService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #27
Source File: license-scan-result-item.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('LicenseScanResultItemItemService', () => {
  let service: LicenseScanResultItemService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        LicenseScanResultItemService,
        {
          provide: getRepositoryToken(LicenseScanResultItem),
          useClass: mockRepository,
        },
        {
          provide: 'LicenseStatusDeploymentTypeService',
          useClass: jest.fn(),
        },
      ],
    }).compile();

    service = module.get<LicenseScanResultItemService>(LicenseScanResultItemService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #28
Source File: license-status-deployment-type.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('LicenseStatusDeploymentTypeService', () => {
  let service: LicenseStatusDeploymentTypeService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        LicenseStatusDeploymentTypeService,
        {
          provide: getRepositoryToken(LicenseStatusDeploymentType),
          useClass: mockRepository,
        },
      ],
    }).compile();

    service = module.get<LicenseStatusDeploymentTypeService>(LicenseStatusDeploymentTypeService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});
Example #29
Source File: obligation.service.spec.ts    From barista with Apache License 2.0 6 votes vote down vote up
describe('ObligationService', () => {
  let service: ObligationService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [ObligationService, { provide: getRepositoryToken(Obligation), useClass: mockRepository }],
    }).compile();

    service = module.get<ObligationService>(ObligationService);
  });

  it('should be defined', () => {
    expect(service).toBeDefined();
  });
});