varabyte / kotter

A declarative, Kotlin-idiomatic API for writing dynamic console applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

terminal.assertMatches not behaving as expected when testing input

Nereboss opened this issue · comments

Describe the bug
When testing if the initial formatting of a block containing input is correct with assertMatches, it throws an error but shows the same strings in the error message.

To Reproduce
Steps to reproduce the behavior:

  1. This simple test method can be used to (hopefully) reproduce this issue:
@Test
    fun `test for input formatting`() {
        testSession { terminal ->
            section {
                input()
            }.runUntilSignal {
                terminal.assertMatches { text("\\e[7m ") }         //inside the text is the code for the cursors blinking
            }
        }
    }
  1. Run the test, it should fail and display the same strings for the actual and the expected like this:
    image

Expected behavior
As both strings displayed in the error are exactly the same (and tests that use stripFormatting confirm that except for formatting everything matches), such a test should run.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS
  • Version 1.1.2

Additional context
I know that such a test is 'faking' the input method with a text field and manually putting in ansi codes but there is no other method to test against. Maybe a function could be added to test input and handle all ansi codes

Update: using the invert function instead of manually putting in the ansi code for blinking (\e[7m) fixes this issue