Skip to content

Commit

Permalink
Add StartFormat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattking committed Jul 29, 2024
1 parent fb05cbc commit ffc32b1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/main/kotlin/info/mking/k2zpl/builder/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
package info.mking.k2zpl.builder

import info.mking.k2zpl.command.EndFormat
import info.mking.k2zpl.command.StartFormat
import info.mking.k2zpl.command.ZplCommand
import info.mking.k2zpl.command.options.ZplFont
import info.mking.k2zpl.command.options.ZplYesNo

/**
* Starts the label format.
*/
fun ZplBuilder.startFormat() {
command(StartFormat)
}

/**
* Ends the label format.
*/
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/info/mking/k2zpl/command/StartFormat.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package info.mking.k2zpl.command

import info.mking.k2zpl.builder.ZplBuilder
import info.mking.k2zpl.builder.command

internal data object StartFormat : ZplCommand {
override val command: CharSequence = "^XA"
}

/**
* Starts the label format.
*/
fun ZplBuilder.startFormat() {
command(StartFormat)
}
25 changes: 25 additions & 0 deletions src/test/kotlin/info/mking/k2zpl/command/StartFormatTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package info.mking.k2zpl.command

import info.mking.k2zpl.k2zpl
import info.mking.k2zpl.testBuildString
import io.kotest.core.spec.IsolationMode
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.shouldBe

class StartFormatTest : DescribeSpec({
isolationMode = IsolationMode.InstancePerLeaf

describe("StartFormat") {
it("outputs correct command") {
StartFormat.testBuildString() shouldBe "^XA"
}
}
describe("startFormat extension function") {
it("outputs correct command") {
val result = k2zpl {
startFormat()
}
result shouldBe "^XA\n"
}
}
})

0 comments on commit ffc32b1

Please sign in to comment.