Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenHalman committed Mar 17, 2024
1 parent 7607c77 commit e6ef94a
Show file tree
Hide file tree
Showing 2 changed files with 214 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/UnusedVariables.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expect } from 'chai';
import 'mocha';
import * as core from '../src'
import SendEmailFlow from './testfiles/SendEmailFlow.json';


describe('The Unused Variables Rule', () => {
let flow: core.Flow;

it('there should be no result for variables used in text elements', () => {
const ruleConfig = {
rules:
{
UnusedVariable:
{
severity: 'error',
},
}
};
flow = new core.Flow({
path: './testfiles/SendEmailFlow.flow',
xmldata: SendEmailFlow,
});
const results: core.ScanResult[] = core.scan([flow], ruleConfig);
const occurringResults = results[0].ruleResults.filter((rule) => rule.occurs);
expect(occurringResults.length).to.equal(0);
});

});

184 changes: 184 additions & 0 deletions tests/testfiles/SendEmailFlow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"Flow": {
"$": {
"xmlns": "http://soap.sforce.com/2006/04/metadata"
},
"actionCalls": [
{
"name": [
"Send_Email"
],
"label": [
"Send Email"
],
"locationX": [
"176"
],
"locationY": [
"323"
],
"actionName": [
"emailSimple"
],
"actionType": [
"emailSimple"
],
"flowTransactionModel": [
"CurrentTransaction"
],
"inputParameters": [
{
"name": [
"emailSubject"
],
"value": [
{
"stringValue": [
"My Subject"
]
}
]
},
{
"name": [
"emailBody"
],
"value": [
{
"elementReference": [
"myTextTemplate"
]
}
]
},
{
"name": [
"recipientId"
],
"value": [
{
"elementReference": [
"$User.Id"
]
}
]
}
],
"nameSegment": [
"emailSimple"
],
"versionSegment": [
"1"
]
}
],
"apiVersion": [
"60.0"
],
"environments": [
"Default"
],
"formulas": [
{
"name": [
"myFormula"
],
"dataType": [
"DateTime"
],
"expression": [
"NOW()"
]
}
],
"interviewLabel": [
"SendEmailFlow {!$Flow.CurrentDateTime}"
],
"label": [
"SendEmailFlow"
],
"processMetadataValues": [
{
"name": [
"BuilderType"
],
"value": [
{
"stringValue": [
"LightningFlowBuilder"
]
}
]
},
{
"name": [
"CanvasMode"
],
"value": [
{
"stringValue": [
"AUTO_LAYOUT_CANVAS"
]
}
]
},
{
"name": [
"OriginBuilderType"
],
"value": [
{
"stringValue": [
"LightningFlowBuilder"
]
}
]
}
],
"processType": [
"AutoLaunchedFlow"
],
"start": [
{
"locationX": [
"50"
],
"locationY": [
"0"
],
"connector": [
{
"targetReference": [
"Send_Email"
]
}
],
"object": [
"Account"
],
"recordTriggerType": [
"Create"
],
"triggerType": [
"RecordAfterSave"
]
}
],
"status": [
"Draft"
],
"textTemplates": [
{
"name": [
"myTextTemplate"
],
"isViewedAsPlainText": [
"false"
],
"text": [
"<p>{!myFormula}</p>"
]
}
]
}
}

0 comments on commit e6ef94a

Please sign in to comment.