Skip to content

Commit df1afec

Browse files
SamNie2027benjaspetthaninbew
authored
23 Donation e2e integration and controller unit testing (#28)
* E2E test stubs * feat: donations controller impl * Some failure tests, adding supertest and expanding jest.config.ts to recognize tests in /test folder * SqLite setup and longer setup timeout * Using enums, testing for umbrella db throws error, GET cases if db is empty * Passing success tests * Test cases for missing responses and expanded DTO validation * reformatting * Fixed DTO field test * Removing unnecessary cases * Changed wording to be clearer * validation to match real service behavior * Rename donations.e2e-spec.ts to donations.controller.spec.ts * Tests pass e2e without db state check or cleanup yet * Tests don't actually pass e2e, no db state check or cleanup yet * Temporary logging, using actual db * Database entry validation, uses donation transactions * Removing console.logs and moving most of the donation with mock tests into donation.spec.ts * Fix for created at, may reduce performance(?) * Fix for returning non-anonymous donations * New migration created for int amount * Defaulting createdAt and updatedAt , tests pass * change test DB creds and add environment variables --------- Co-authored-by: Ben Petrillo <benpetrillo.bp@gmail.com> Co-authored-by: thaninbew <kongkiatsophon.t@northeastern.edu>
1 parent 28e9c06 commit df1afec

File tree

10 files changed

+2100
-77
lines changed

10 files changed

+2100
-77
lines changed

apps/backend/jest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export default {
88
},
99
moduleFileExtensions: ['ts', 'js', 'html'],
1010
coverageDirectory: '../../coverage/apps/backend',
11+
testMatch: ['<rootDir>/src/**/*.spec.ts', '<rootDir>/test/**/*.spec.ts', '<rootDir>/test/**/*.e2e-spec.ts'],
1112
};

apps/backend/src/donations/donation.entity.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
1+
import {
2+
Entity,
3+
PrimaryGeneratedColumn,
4+
Column,
5+
CreateDateColumn,
6+
UpdateDateColumn,
7+
} from 'typeorm';
28

39
export enum DonationType {
410
ONE_TIME = 'one_time',
@@ -36,7 +42,7 @@ export class Donation {
3642
@Column()
3743
email: string;
3844

39-
@Column({ type: 'numeric', precision: 10, scale: 2 })
45+
@Column({ type: 'int' })
4046
amount: number;
4147

4248
@Column({ default: false })
@@ -60,9 +66,9 @@ export class Donation {
6066
@Column({ nullable: true })
6167
transactionId: string | null;
6268

63-
@Column()
69+
@CreateDateColumn({ type: 'timestamp', default: () => 'now()' })
6470
createdAt: Date;
6571

66-
@Column()
72+
@UpdateDateColumn({ type: 'timestamp', default: () => 'now()' })
6773
updatedAt: Date;
6874
}

0 commit comments

Comments
 (0)