Skip to content

Commit

Permalink
Add EndFormat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattking committed Jul 29, 2024
1 parent ffc32b1 commit 202635d
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 @@ -2,18 +2,10 @@

package info.mking.k2zpl.builder

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

/**
* Ends the label format.
*/
fun ZplBuilder.endFormat() {
command(EndFormat)
}

/**
* Shortcut for addCommand
*/
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/info/mking/k2zpl/command/EndFormat.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 EndFormat : ZplCommand {
override val command: CharSequence = "^XZ"
}

/**
* Ends the label format.
*/
fun ZplBuilder.endFormat() {
command(EndFormat)
}
25 changes: 25 additions & 0 deletions src/test/kotlin/info/mking/k2zpl/command/EndFormatTest.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 EndFormatTest : DescribeSpec({
isolationMode = IsolationMode.InstancePerLeaf

describe("EndFormat") {
it("outputs correct command") {
EndFormat.testBuildString() shouldBe "^XZ"
}
}
describe("endFormat extension fucntion") {
it("outputs correct command") {
val result = k2zpl {
endFormat()
}
result shouldBe "^XZ\n"
}
}
})

0 comments on commit 202635d

Please sign in to comment.