From ffc32b160ce3559c5753a4558da515280b96be7a Mon Sep 17 00:00:00 2001 From: Matt King Date: Mon, 29 Jul 2024 07:33:41 +0100 Subject: [PATCH] Add StartFormat tests --- .../info/mking/k2zpl/builder/Extensions.kt | 8 ------ .../info/mking/k2zpl/command/StartFormat.kt | 10 ++++++++ .../mking/k2zpl/command/StartFormatTest.kt | 25 +++++++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 src/test/kotlin/info/mking/k2zpl/command/StartFormatTest.kt diff --git a/src/main/kotlin/info/mking/k2zpl/builder/Extensions.kt b/src/main/kotlin/info/mking/k2zpl/builder/Extensions.kt index 9de138d..8fe54b2 100644 --- a/src/main/kotlin/info/mking/k2zpl/builder/Extensions.kt +++ b/src/main/kotlin/info/mking/k2zpl/builder/Extensions.kt @@ -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. */ diff --git a/src/main/kotlin/info/mking/k2zpl/command/StartFormat.kt b/src/main/kotlin/info/mking/k2zpl/command/StartFormat.kt index 4359772..886b211 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/StartFormat.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/StartFormat.kt @@ -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) } \ No newline at end of file diff --git a/src/test/kotlin/info/mking/k2zpl/command/StartFormatTest.kt b/src/test/kotlin/info/mking/k2zpl/command/StartFormatTest.kt new file mode 100644 index 0000000..c1f55d2 --- /dev/null +++ b/src/test/kotlin/info/mking/k2zpl/command/StartFormatTest.kt @@ -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" + } + } +}) \ No newline at end of file