Skip to content

Commit d9065ef

Browse files
rtkay123rtkay123
andauthored
Remove desc from rule and typology results (#63)
* tests: exclude `desc` from typology result * chore: bump lib ver --------- Co-authored-by: rtkay123 <[email protected]>
1 parent 9146a85 commit d9065ef

File tree

3 files changed

+71
-28
lines changed

3 files changed

+71
-28
lines changed

__tests__/unit/logic.test.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('TADProc Service', () => {
9494
};
9595

9696
const getMockTypologyResult = (ruleResults: RuleResult[]): TypologyResult => {
97-
return { result: 50, id: '[email protected]', cfg: '[email protected]', desc: 'test', threshold: 0, ruleResults };
97+
return { result: 50, id: '[email protected]', cfg: '[email protected]', threshold: 0, ruleResults };
9898
};
9999

100100
const getMockNetworkMapWithMultipleChannels = () => {
@@ -487,26 +487,24 @@ describe('TADProc Service', () => {
487487
return Promise.resolve();
488488
});
489489

490-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
490+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
491491

492492
jest.spyOn(databaseManager, 'addOneGetCount').mockImplementation((...args: unknown[]): Promise<number> => {
493493
return Promise.resolve(1);
494494
});
495495

496496
jest.spyOn(databaseManager, 'getMemberValues').mockImplementation((...args: unknown[]): Promise<Record<string, unknown>[]> => {
497-
return Promise.resolve([
498-
{ typologyResult: { result: 50, id: '[email protected]', cfg: '[email protected]', desc: 'test', threshold: 0, ruleResults } },
499-
]);
497+
return Promise.resolve([{ typologyResult: { result: 50, id: '[email protected]', cfg: '[email protected]', threshold: 0, ruleResults } }]);
500498
});
501499
});
502500

503501
it('should handle successful request, with an unmatched number', async () => {
504502
const expectedReq = getMockTransaction();
505503

506-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
504+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
507505

508506
const networkMap = getMockNetworkMapWithMultipleChannels();
509-
const typologyResult: TypologyResult = { result: 50, id: '[email protected]', cfg: '[email protected]', desc: 'test', threshold: 0, ruleResults };
507+
const typologyResult: TypologyResult = { result: 50, id: '[email protected]', cfg: '[email protected]', threshold: 0, ruleResults };
510508

511509
await helpers.handleTypologies(expectedReq, networkMap.messages[0].channels[0], networkMap, typologyResult);
512510

@@ -516,7 +514,7 @@ describe('TADProc Service', () => {
516514
it('should handle successful request, with a matched number', async () => {
517515
const expectedReq = getMockTransaction();
518516

519-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
517+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
520518
const networkMap = getMockNetworkMap();
521519
const typologyResult: TypologyResult = getMockTypologyResult(ruleResults);
522520

@@ -535,7 +533,7 @@ describe('TADProc Service', () => {
535533
);
536534
});
537535

538-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
536+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
539537
const networkMap = getMockNetworkMapWithMultipleChannels();
540538
const typologyResult: TypologyResult = getMockTypologyResult(ruleResults);
541539

@@ -550,7 +548,7 @@ describe('TADProc Service', () => {
550548
});
551549
const expectedReq = getMockTransaction();
552550

553-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
551+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
554552
const networkMap = getMockNetworkMap();
555553
const typologyResult: TypologyResult = getMockTypologyResult(ruleResults);
556554

@@ -561,7 +559,7 @@ describe('TADProc Service', () => {
561559

562560
it('should handle successful request, not all results yet', async () => {
563561
const expectedReq = getMockTransaction();
564-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
562+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
565563

566564
const networkMap = getMockNetworkMapWithMultipleChannels();
567565
const typologyResult: TypologyResult = getMockTypologyResult(ruleResults);
@@ -573,7 +571,7 @@ describe('TADProc Service', () => {
573571

574572
it('should respond with error if cache key deletion fails', async () => {
575573
const expectedReq = getMockTransaction();
576-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
574+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
577575

578576
const networkMap = getMockNetworkMapWithMultipleChannels();
579577
const typologyResult: TypologyResult = getMockTypologyResult(ruleResults);
@@ -585,7 +583,7 @@ describe('TADProc Service', () => {
585583

586584
it('should respond with error if nothing comes back from cache', async () => {
587585
const expectedReq = getMockTransaction();
588-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
586+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
589587

590588
jest.spyOn(databaseManager, 'deleteKey').mockRejectedValueOnce((key: string) => {
591589
return Promise.reject();
@@ -601,7 +599,7 @@ describe('TADProc Service', () => {
601599

602600
it('should respond with error if NATS communication Error Occures', async () => {
603601
const expectedReq = getMockTransaction();
604-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
602+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
605603

606604
jest.spyOn(server, 'handleResponse').mockRejectedValueOnce((value: string) => {
607605
return Promise.reject();
@@ -618,7 +616,7 @@ describe('TADProc Service', () => {
618616
it('should respond with error if message is missing from networkmap', async () => {
619617
const expectedReq = getMockTransaction();
620618

621-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
619+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
622620
const networkMap = getMockNetworkMapNoMessages();
623621
const typologyResult: TypologyResult = getMockTypologyResult(ruleResults);
624622

@@ -633,10 +631,10 @@ describe('TADProc Service', () => {
633631
it('should handle a successful transaction, incomplete.', async () => {
634632
const expectedReq = getMockTransaction();
635633

636-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
634+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
637635

638636
const networkMap = getMockNetworkMapWithMultipleChannels();
639-
const typologyResult: TypologyResult = { result: 50, id: '[email protected]', cfg: '[email protected]', desc: 'test', threshold: 0, ruleResults };
637+
const typologyResult: TypologyResult = { result: 50, id: '[email protected]', cfg: '[email protected]', threshold: 0, ruleResults };
640638

641639
await handleExecute({ transaction: expectedReq, networkMap: networkMap, typologyResult: typologyResult });
642640

@@ -645,10 +643,10 @@ describe('TADProc Service', () => {
645643

646644
it('should handle a successful transaction, complete.', async () => {
647645
const expectedReq = getMockTransaction();
648-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
646+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
649647

650648
const networkMap = getMockNetworkMap();
651-
const typologyResult: TypologyResult = { result: 50, id: '[email protected]', cfg: '[email protected]', desc: 'test', threshold: 0, ruleResults };
649+
const typologyResult: TypologyResult = { result: 50, id: '[email protected]', cfg: '[email protected]', threshold: 0, ruleResults };
652650

653651
const typologySpy = jest.spyOn(helpers, 'handleTypologies').mockImplementationOnce(() => {
654652
return Promise.resolve([
@@ -683,10 +681,10 @@ describe('TADProc Service', () => {
683681

684682
it('should handle a successful transaction, with review.', async () => {
685683
const expectedReq = getMockTransaction();
686-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
684+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
687685

688686
const networkMap = getMockNetworkMap();
689-
const typologyResult: TypologyResult = { result: 50, id: '[email protected]', cfg: '[email protected]', desc: 'test', threshold: 100, ruleResults };
687+
const typologyResult: TypologyResult = { result: 50, id: '[email protected]', cfg: '[email protected]', threshold: 100, ruleResults };
690688

691689
const typologySpy = jest.spyOn(helpers, 'handleTypologies').mockImplementationOnce(() => {
692690
return Promise.resolve([
@@ -723,10 +721,10 @@ describe('TADProc Service', () => {
723721

724722
it('should handle a unsuccessful transaction, catch error.', async () => {
725723
const expectedReq = getMockTransaction();
726-
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '', desc: '' }];
724+
const ruleResults: RuleResult[] = [{ result: true, id: '', cfg: '', subRuleRef: '', reason: '' }];
727725

728726
const networkMap = getMockNetworkMap();
729-
const typologyResult: TypologyResult = { result: 50, id: '[email protected]', cfg: '[email protected]', desc: 'test', threshold: 0, ruleResults };
727+
const typologyResult: TypologyResult = { result: 50, id: '[email protected]', cfg: '[email protected]', threshold: 0, ruleResults };
730728

731729
const typologySpy = jest.spyOn(helpers, 'handleTypologies').mockRejectedValueOnce(() => {
732730
return Promise.reject();

package-lock.json

Lines changed: 49 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
],
4040
"license": "ISC",
4141
"dependencies": {
42-
"@frmscoe/frms-coe-lib": "^1.2.5",
42+
"@frmscoe/frms-coe-lib": "^2.0.0",
4343
"@frmscoe/frms-coe-startup-lib": "^2.0.1",
4444
"@log4js-node/logstash-http": "^1.1.0",
4545
"arangojs": "^8.4.0",

0 commit comments

Comments
 (0)