-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(embed): write unit tests for embed generator utility functions
- Loading branch information
1 parent
381ea53
commit ff35be7
Showing
5 changed files
with
105 additions
and
10 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
5 changes: 5 additions & 0 deletions
5
packages/embed/src/renderer/content/tests/html-generator.test.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,5 @@ | ||
describe('Test HTML generator functions', () => { | ||
it('should generates html content for a non existing code snippet', () => {}); | ||
|
||
it('should generates html content for a code snippet', () => {}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
packages/embed/src/renderer/content/tests/preview-template.test.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,5 @@ | ||
describe('Test generateHTMLPreview()', () => { | ||
it('should generates the html preview for a non existing code snippet', () => {}); | ||
|
||
it('should generates the html preview for a code snippet', () => {}); | ||
}); |
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,81 @@ | ||
import { addWhitespaceForEmptyLine, generateLineHighlightOptions } from '../utils'; | ||
|
||
describe('Test utils functions', () => { | ||
describe('Test addWhitespaceForEmptyLine()', () => { | ||
it('should create not whitespace for a simple span tag', () => { | ||
// GIVEN | ||
const line = `<span></span>`; | ||
|
||
// WHEN | ||
const result = addWhitespaceForEmptyLine(line); | ||
// THEN | ||
|
||
expect(result).toEqual(`<span></span>`); | ||
}); | ||
|
||
it('should create whitespace for a code line', () => { | ||
// GIVEN | ||
const line = `<span class="line"></span>`; | ||
|
||
// WHEN | ||
const result = addWhitespaceForEmptyLine(line); | ||
|
||
// THEN | ||
expect(result).toEqual(`<span class="line"> </span>`); | ||
}); | ||
|
||
it('should create whitespace for a code line with highlight', () => { | ||
// GIVEN | ||
const line = `<span class="line line-diff-add"></span>`; | ||
|
||
// WHEN | ||
const result = addWhitespaceForEmptyLine(line); | ||
// THEN | ||
|
||
expect(result).toEqual(`<span class="line line-diff-add"> </span>`); | ||
}); | ||
}); | ||
|
||
describe.only('Test generateLineHighlightOptions()', () => { | ||
it('should generate no line highlight options from a null string', () => { | ||
// GIVEN | ||
const lineHighlight: string | null = null; | ||
|
||
// WHEN | ||
const result = generateLineHighlightOptions(lineHighlight); | ||
|
||
// THEN | ||
expect(result).toMatchObject([]); | ||
}); | ||
|
||
it('should generate no line highlight options from an empty string', () => { | ||
// GIVEN | ||
const lineHighlight = `[]`; | ||
|
||
// WHEN | ||
const result = generateLineHighlightOptions(lineHighlight); | ||
|
||
// THEN | ||
expect(result).toMatchObject([]); | ||
}); | ||
|
||
it('should generate line highlight options from string', () => { | ||
// GIVEN | ||
const lineHighlight = `[[3,"delete"],[6,"blur"],[7,"add"]]`; | ||
|
||
// WHEN | ||
const result = generateLineHighlightOptions(lineHighlight); | ||
|
||
// THEN | ||
const expectedResult = [ | ||
{ classes: ['line-diff line-diff-delete'], line: 3 }, | ||
{ classes: ['line-diff line-diff-blur'], line: 6 }, | ||
{ classes: ['line-diff line-diff-add'], line: 7 }, | ||
]; | ||
|
||
expect(result).toMatchObject(expectedResult); | ||
}); | ||
}); | ||
|
||
describe('Test parseHTMLSnippetCode()', () => {}); | ||
}); |
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