Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickleet committed Mar 11, 2022
1 parent a99c26e commit ecc0f05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
35 changes: 1 addition & 34 deletions __tests__/integration/persistenceLayer-postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ const postgresConnectionUrl =
process.env.POSTGRES_URL ||
"postgresql://sourced:sourced@localhost:5432/sourced";


describe('error', () => {
describe("error", () => {
it("should throw an error if trying to initialize a repository before connection has been established", () => {
try {
new Repository(Person);
Expand Down Expand Up @@ -79,10 +78,8 @@ describe("sourced-repo-typeorm", () => {
afterAll(async () => {
await persistenceLayer?.disconnect();
});


it("should connect to persistenceLayer, get and commit Entities, then disconnect", async () => {

const personRepository = new Repository(Person);

const person1 = await personRepository.get(1);
Expand Down Expand Up @@ -148,12 +145,6 @@ describe("sourced-repo-typeorm", () => {
hpFromMultipleSnapshots.on("birthday", async (wizard) => {
log("birthday event handler");
expect(wizard.age).toBe(41);

// try {
// await persistenceLayer.disconnect();
// } finally {
// expect(persistenceLayer.connection).toBeDefined();
// }
});

hpFromMultipleSnapshots.birthday();
Expand All @@ -165,16 +156,6 @@ describe("sourced-repo-typeorm", () => {
const now = Date.now();
log("duplicate event test...");

// try {
// await persistenceLayer.connect({
// type: "postgres",
// url: postgresConnectionUrl,
// connectTimeoutMS: 1000,
// });
// } finally {
// expect(persistenceLayer.connection).toBeDefined();
// }

const id = `test-dupe-${now}`;

const personRepository = new Repository(Person);
Expand All @@ -200,21 +181,9 @@ describe("sourced-repo-typeorm", () => {
expect(err.detail).toBeDefined();
expect(err.code).toBe("23505");
}

// await persistenceLayer.disconnect();
});

it("should be able to force a snapshot with options on commit", async () => {
// try {
// await persistenceLayer.connect({
// type: "postgres",
// url: postgresConnectionUrl,
// connectTimeoutMS: 1000,
// });
// } finally {
// expect(persistenceLayer.connection).toBeDefined();
// }

const personRepository = new Repository(Person);

const person = new Person();
Expand All @@ -227,8 +196,6 @@ describe("sourced-repo-typeorm", () => {

expect(person.version).toBe(3);
expect(person.snapshotVersion).toBe(3);

// await persistenceLayer.disconnect();
});
});

Expand Down
3 changes: 2 additions & 1 deletion src/Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export class Repository extends EventEmitter {
});

if (
this.forceSnapshot || options?.forceSnapshot ||
this.forceSnapshot ||
options?.forceSnapshot ||
entity.version >= entity.snapshotVersion + this.snapshotFrequency
) {
const snapshot = entity.snapshot();
Expand Down

0 comments on commit ecc0f05

Please sign in to comment.