Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Designer): Revert - Updated HTML Editor to support newline charac…
…ters (#4807) * Revert "fix(Designer): Updated HTML Editor to support newline characters (for dynamic content) (#4635)" This reverts commit f4e1f8b. * adding test * adding another test
- Loading branch information
Showing
6 changed files
with
63 additions
and
43 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
libs/designer-ui/src/lib/editor/base/utils/__test__/helper.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { ValueSegmentType } from '../../../models/parameter'; | ||
import { createLiteralValueSegment, createEmptyLiteralValueSegment, removeFirstAndLast } from '../helper'; | ||
|
||
describe('Helper functions', () => { | ||
it('creates a literal value segment', () => { | ||
const segment = createLiteralValueSegment('test', '1'); | ||
expect(segment).toEqual({ | ||
id: '1', | ||
type: ValueSegmentType.LITERAL, | ||
value: 'test', | ||
}); | ||
}); | ||
|
||
it('creates an empty literal value segment', () => { | ||
const segment = createEmptyLiteralValueSegment(); | ||
expect(segment).toEqual({ | ||
id: expect.any(String), // The id is generated by guid(), so we can't know its exact value | ||
type: ValueSegmentType.LITERAL, | ||
value: '', | ||
}); | ||
}); | ||
|
||
it('removes first and last characters from segments', () => { | ||
const segments = [ | ||
{ id: '1', type: ValueSegmentType.LITERAL, value: 'test' }, | ||
{ id: '2', type: ValueSegmentType.LITERAL, value: 'example' }, | ||
]; | ||
const result = removeFirstAndLast(segments, 't', 'e'); | ||
expect(result).toEqual([ | ||
{ id: '1', type: ValueSegmentType.LITERAL, value: 'est' }, | ||
{ id: '2', type: ValueSegmentType.LITERAL, value: 'exampl' }, | ||
]); | ||
}); | ||
}); |
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
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
17 changes: 17 additions & 0 deletions
17
libs/designer-ui/src/lib/html/plugins/toolbar/helper/__test__/HtmlChangePlugin.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { HTMLChangePlugin } from '../HTMLChangePlugin'; | ||
import { test } from 'vitest'; | ||
|
||
test('HTMLChangePlugin can be used', () => { | ||
const mockProps = { | ||
isValuePlaintext: false, | ||
setIsSwitchFromPlaintextBlocked: () => {}, | ||
setIsValuePlaintext: () => {}, | ||
setValue: () => {}, | ||
}; | ||
|
||
try { | ||
HTMLChangePlugin(mockProps); | ||
} catch (e) { | ||
throw new Error(`HTMLChangePlugin could not be used: ${e}`); | ||
} | ||
}); |
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