Skip to content

Commit

Permalink
Accounting folder operations (#219)
Browse files Browse the repository at this point in the history
* feat(/events/accountingFolder): delete operation

* doc(/events/accountingFolder: delete operation

* test(UT/utils/index): updated ut accountingFolder operation
  • Loading branch information
Rossb0b authored Mar 26, 2024
1 parent 43e0aa0 commit dc0efe2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Event notifying the creation of a new Accounting Folder (a company).

```ts
export type AccountingFolderOperation = Operation[
keyof Pick<Operation, "create" | "update">
keyof Pick<Operation, "create" | "update" | "delete">
];

export type AccountingFolderScope = Scope & Required<Pick<Scope, "firmId">>;
Expand Down
2 changes: 1 addition & 1 deletion docs/json-schema/events/accountingFolder.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"operation": {
"type": "string",
"description": "Operation operated next to the event",
"enum": ["CREATE", "UPDATE"]
"enum": ["CREATE", "UPDATE", "DELETE"]
},
"scope": {
"type": "object",
Expand Down
11 changes: 11 additions & 0 deletions src/schema/events/accountingFolder.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
"required": ["id"],
"additionalProperties": false
},
"delete": {
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "^[0-9]+"
}
},
"required": ["id"],
"additionalProperties": false
},
"scope": {
"type": "object",
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface Connector {
}

export type AccountingFolderOperation = Operation[
keyof Pick<Operation, "create" | "update">
keyof Pick<Operation, "create" | "update" | "delete">
];

export type AccountingFolderScope = Scope & Required<Pick<Scope, "firmId">>;
Expand Down
6 changes: 3 additions & 3 deletions test/UT/utils/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ describe("eventsValidationFn", () => {
accountingFolder = eventsValidationFn.get("accountingFolder");
});

test("accountingFolder should have a validation function for \"create\" & \"update\" & \"scope\"", () => {
test("accountingFolder should have a validation function for \"create\", \"update\", \"delete\", \"scope\"", () => {
expect(accountingFolder.has("create")).toBe(true);
expect(accountingFolder.has("update")).toBe(true);
expect(accountingFolder.has("delete")).toBe(true);
expect(accountingFolder.has("scope")).toBe(true);
});

test("accountingFolder should not have a validation function for \"delete\", \"void\"", () => {
expect(accountingFolder.has("delete")).toBe(false);
test("accountingFolder should not have a validation function for \"void\"", () => {
expect(accountingFolder.has("void")).toBe(false);
});
});
Expand Down

0 comments on commit dc0efe2

Please sign in to comment.