-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from bvandercar-vt/consoleprocessor-bold
feat: console logging accommodate cy.log message markdown
- Loading branch information
Showing
5 changed files
with
159 additions
and
6 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
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,21 @@ | ||
describe('cy.log markdown.', () => { | ||
/** | ||
* Covers: cy.log markdown to console | ||
*/ | ||
it('cy.log markdown.', () => { | ||
cy.log('_This is an_italic* log._'); | ||
cy.log('*This is an_italic* log.*'); | ||
cy.log('**This is a__bold* log.**'); | ||
cy.log('__This is a__bold* log.__'); | ||
cy.log('***This is a_bold and italic* log.***'); | ||
cy.log('___This is a_bold and italic* log.___'); | ||
cy.log('_This is a normal log'); | ||
cy.log('This is a normal log_'); | ||
cy.log('__This is a normal log'); | ||
cy.log('This is a normal log__'); | ||
cy.log('*This is a normal log'); | ||
cy.log('This is a normal log*'); | ||
cy.log('**This is a normal log'); | ||
cy.log('This is a normal log**'); | ||
}); | ||
}); |
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,36 @@ | ||
import utils from '../../src/utils'; | ||
import {expect} from 'chai'; | ||
|
||
const {applyMessageMarkdown} = utils; | ||
|
||
describe('utils', () => { | ||
describe('applyMessageMarkdown', () => { | ||
it('correctly detects markdown and returns processed message with functions applied', () => { | ||
const LONG_MSG = 'abc123'.repeat(5); | ||
const tests = [ | ||
['*text text*', '<i>text text<i>'], | ||
['_text text_', '<i>text text<i>'], | ||
['**text text**', '<b>text text<b>'], | ||
['__text text__', '<b>text text<b>'], | ||
['***text text***', '<b><i>text text<i><b>'], | ||
['___text text___', '<b><i>text text<i><b>'], | ||
['_text text_text_', '<i>text text_text<i>'], | ||
['text text_', 'text text_'], | ||
['*text text', '*text text'], | ||
['*text text**', '<i>text text*<i>'], | ||
['**text text*', '<i>*text text<i>'], | ||
[`**${LONG_MSG}**`, `<b>${LONG_MSG.substring(0, 20)}...<b>`], | ||
]; | ||
tests.forEach(([message, expected]) => { | ||
expect( | ||
applyMessageMarkdown(message, { | ||
bold: (str) => `<b>${str}<b>`, | ||
italic: (str) => `<i>${str}<i>`, | ||
processContents: (c) => (c.length > 20 ? c.substring(0, 20) + '...' : c), | ||
}), | ||
message | ||
).to.deep.equal(expected); | ||
}); | ||
}); | ||
}); | ||
}); |