-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✅ Added basic test utils and tests for replace operator
- Loading branch information
Showing
2 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
20 changes: 14 additions & 6 deletions
20
libs/language-server/src/lib/ast/expressions/evaluators/replace-operator-evaluator.spec.ts
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 |
---|---|---|
@@ -1,16 +1,24 @@ | ||
// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
import { executeExpressionTestHelper } from '../test-utils'; | ||
import { executeDefaultTextToTextExpression } from '../test-utils'; | ||
|
||
describe('The replace operator', () => { | ||
it('should replace text successfully', async () => { | ||
const result = await executeExpressionTestHelper( | ||
"inputValue replace /test/ with 'works'", | ||
'inputValue', | ||
'test', | ||
const result = await executeDefaultTextToTextExpression( | ||
"inputValue replace /Test/ with 'World'", | ||
'Hello Test', | ||
); | ||
|
||
expect(result).toEqual('test'); | ||
expect(result).toEqual('Hello World'); | ||
}); | ||
|
||
it('should be able to replace text with nothing', async () => { | ||
const result = await executeDefaultTextToTextExpression( | ||
"inputValue replace / Test/ with ''", | ||
'Hello Test', | ||
); | ||
|
||
expect(result).toEqual('Hello'); | ||
}); | ||
}); |
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