Skip to content

Commit e38d008

Browse files
committed
fix(testers): ensure RuleTester verifies meta property
Related to #165
1 parent ac9eaa4 commit e38d008

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/testers/rule-tester.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function verify(ruleName, rule, testCases) {
4141

4242
testCases.valid.forEach(({ config = {}, it: _it, moddleElement, name }, idx) => (
4343

44-
(_it || it)(getTitle(idx, name), function() {
44+
(_it || it)(getTitle(idx, name), async function() {
45+
4546
return (
4647
Promise.resolve(moddleElement)
4748
.then(moddleRoot => {
@@ -70,9 +71,14 @@ function verify(ruleName, rule, testCases) {
7071
];
7172
}
7273

74+
const {
75+
meta
76+
} = await linter.resolveRule(name, config);
77+
7378
const expectedResults = report.map(report => {
7479
return {
7580
...report,
81+
meta,
7682
category: 'error'
7783
};
7884
});

test/spec/testers/rule-tester-spec.mjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,34 @@ describe('rule-tester', function() {
149149

150150
});
151151

152+
153+
describe('with <meta>', function() {
154+
155+
const meta = { foo: 1 };
156+
157+
verify('with-local-config', (config) => {
158+
return {
159+
check: (node, reporter) => {
160+
reporter.report(node.get('id'), config);
161+
},
162+
meta
163+
};
164+
}, {
165+
valid: [],
166+
invalid: [
167+
{
168+
name: 'with config',
169+
config: 'foo',
170+
moddleElement: createModdle('<bpmn:Task id="Task_1" />', 'bpmn:Task'),
171+
report: {
172+
id: 'Task_1',
173+
message: 'foo'
174+
}
175+
}
176+
]
177+
});
178+
179+
});
152180
});
153181

154182
});

0 commit comments

Comments
 (0)