-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(developer): support loose match for CompilerEvents
Fixes: feat(developer): tests CompilerMessage matching should be loose #10943 (also gets us working on Node 20)
- Loading branch information
Showing
3 changed files
with
96 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { CompilerEvent } from '@keymanapp/common-types'; | ||
import 'mocha'; | ||
import {assert} from 'chai'; | ||
import { CompilerEventOrMatch, matchCompilerEvents } from './helpers/index.js'; | ||
import { CompilerMessages } from '../src/compiler/messages.js'; | ||
|
||
|
||
describe('test of test/helpers/CompilerMatch', () => { | ||
/** the message(s) to test */ | ||
const messages : CompilerEvent[] = [ | ||
CompilerMessages.Error_InvalidHardware({ formId: 'outdated' }), | ||
CompilerMessages.Hint_NormalizationDisabled(), | ||
]; | ||
|
||
it('should work for exact matches', () => { | ||
const spec : CompilerEventOrMatch[] = [ | ||
CompilerMessages.Hint_NormalizationDisabled(), | ||
CompilerMessages.Error_InvalidHardware({ formId: 'outdated' }), | ||
]; | ||
const matched = matchCompilerEvents(messages, spec); | ||
assert.sameDeepMembers(messages, spec); // exact match works here | ||
assert.sameDeepMembers(messages, matched); | ||
}); | ||
it('should work for a fuzzy matches', () => { | ||
const spec : CompilerEventOrMatch[] = [ | ||
// mixed messages here - this one is a CompilerEvent | ||
CompilerMessages.Hint_NormalizationDisabled(), | ||
// fuzzy match on this one - CompilerMatch | ||
{ code: CompilerMessages.ERROR_InvalidHardware, matchMessage: /(out|up|inun)dated/ }, | ||
]; | ||
const matched = matchCompilerEvents(messages, spec); | ||
assert.sameDeepMembers(messages, matched); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters