Skip to content

Commit

Permalink
test: update getCommandState test to account for added 'code' command
Browse files Browse the repository at this point in the history
  • Loading branch information
trevinhofmann committed Nov 23, 2024
1 parent 88335b6 commit 333617a
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions src/util/__tests__/getCommandState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ it('empty thought', () => {
italic: false,
underline: false,
strikethrough: false,
code: false,
foreColor: undefined,
backColor: undefined,
})
Expand All @@ -17,6 +18,7 @@ it('bold thought', () => {
italic: false,
underline: false,
strikethrough: false,
code: false,
foreColor: undefined,
backColor: undefined,
})
Expand All @@ -28,6 +30,7 @@ it('italic thought', () => {
italic: true,
underline: false,
strikethrough: false,
code: false,
foreColor: undefined,
backColor: undefined,
})
Expand All @@ -39,6 +42,7 @@ it('underline thought', () => {
italic: false,
underline: true,
strikethrough: false,
code: false,
foreColor: undefined,
backColor: undefined,
})
Expand All @@ -50,17 +54,33 @@ it('strikethrough thought', () => {
italic: false,
underline: false,
strikethrough: true,
code: false,
foreColor: undefined,
backColor: undefined,
})
})

it('code thought', () => {
expect(getCommandState('<code>text</code>')).toStrictEqual({
bold: false,
italic: false,
underline: false,
strikethrough: false,
code: true,
foreColor: undefined,
backColor: undefined,
})
})

it('partially styled thought', () => {
expect(getCommandState('<b>Bold</b><i>Italic</i><u>Underline</u><strike>strikethrough</strike>')).toStrictEqual({
expect(
getCommandState('<b>Bold</b><i>Italic</i><u>Underline</u><strike>strikethrough</strike><code>code</code>'),
).toStrictEqual({
bold: false,
italic: false,
underline: false,
strikethrough: false,
code: false,
foreColor: undefined,
backColor: undefined,
})
Expand All @@ -72,6 +92,7 @@ it('text color thought', () => {
italic: false,
underline: false,
strikethrough: false,
code: false,
foreColor: 'rgb(255, 0, 0)',
backColor: undefined,
})
Expand All @@ -83,6 +104,7 @@ it('background color thought', () => {
italic: false,
underline: false,
strikethrough: false,
code: false,
foreColor: undefined,
backColor: 'rgb(0, 0, 255)',
})
Expand All @@ -91,13 +113,30 @@ it('background color thought', () => {
it('fully styled thought', () => {
expect(
getCommandState(
'<b><i><u><strike><font color="rgb(255, 0, 0)"><span style="background-color: rgb(0, 0, 255)">text</span></font></strike></u></i></b>',
'<b><i><u><strike><code><font color="rgb(255, 0, 0)"><span style="background-color: rgb(0, 0, 255)">text</span></font></code></strike></u></i></b>',
),
).toStrictEqual({
bold: true,
italic: true,
underline: true,
strikethrough: true,
code: true,
foreColor: 'rgb(255, 0, 0)',
backColor: 'rgb(0, 0, 255)',
})
})

it('fully styled thought without text content', () => {
expect(
getCommandState(
'<b><i><u><strike><code><font color="rgb(255, 0, 0)"><span style="background-color: rgb(0, 0, 255)"></span></font></code></strike></u></i></b>',
),
).toStrictEqual({
bold: true,
italic: true,
underline: true,
strikethrough: true,
code: true,
foreColor: 'rgb(255, 0, 0)',
backColor: 'rgb(0, 0, 255)',
})
Expand Down

0 comments on commit 333617a

Please sign in to comment.