Skip to content

Commit

Permalink
fix(cache): fix PlatformCache.keys() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Feb 25, 2022
1 parent 822a88c commit 94d5eba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ export class PlatformCache {
await this.cache?.reset();
}

async keys(): Promise<string[]> {
async keys(...args: any[]): Promise<string[]> {
if (this.cache && "store" in this.cache && this.cache.store.keys) {
return this.cache.store.keys();
return this.cache.store.keys(...args);
}

// istanbul ignore next
Expand Down
11 changes: 6 additions & 5 deletions packages/third-parties/formio/.nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"**/*.d.ts",
"node_modules",
"**/interfaces/**",
"**/index.ts"
"**/index.ts",
"**/*.spec.ts"
],
"extension": [
".ts"
Expand All @@ -19,8 +20,8 @@
"json"
],
"check-coverage": true,
"statements": 99.61,
"branches": 81.2,
"functions": 96.99,
"lines": 99.59
"statements": 100,
"branches": 82.14,
"functions": 100,
"lines": 100
}
12 changes: 10 additions & 2 deletions packages/third-parties/formio/src/services/FormioDatabase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,18 @@ describe("FormioDatabase", () => {
};

formioService.mongoose.models.form.countDocuments.resolves(false);
formioService.mongoose.models.form.exec.resolves({
_id: "id",
name: "name"
});

await service.createFormIfNotExists(form, onCreate);
const result = await service.createFormIfNotExists(form, onCreate);

expect(onCreate).to.have.been.calledWithExactly({ctrOpts: {name: "name"}});
expect(result).to.deep.eq({
_id: "id",
name: "name"
});
expect(onCreate).to.have.been.calledOnce;
});
it("should not create form is exists", async () => {
const {service, formioService} = await createServiceFixture();
Expand Down

0 comments on commit 94d5eba

Please sign in to comment.