Skip to content

Commit

Permalink
Add FieldSeparator test
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattking committed Jul 29, 2024
1 parent 84dacd8 commit e48c1a1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 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 @@ -4,21 +4,13 @@ package info.mking.k2zpl.builder

import info.mking.k2zpl.command.EndFormat
import info.mking.k2zpl.command.FieldData
import info.mking.k2zpl.command.FieldSeparator
import info.mking.k2zpl.command.LabelLength
import info.mking.k2zpl.command.PrintQuantity
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

/**
* Adds a field separator.
*/
fun ZplBuilder.fieldSeparator() {
command(FieldSeparator)
}

/**
* Adds field data.
* @param data The data to be added to the field.
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/info/mking/k2zpl/builder/ZplBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import info.mking.k2zpl.command.CustomCommand
import info.mking.k2zpl.command.Font
import info.mking.k2zpl.command.ZplCommand
import info.mking.k2zpl.command.fieldOrigin
import info.mking.k2zpl.command.fieldSeparator
import info.mking.k2zpl.command.font
import info.mking.k2zpl.command.options.ZplDpiSetting
import info.mking.k2zpl.command.options.ZplFieldOrientation
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/info/mking/k2zpl/command/BarCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package info.mking.k2zpl.command
import info.mking.k2zpl.builder.ZplBuilder
import info.mking.k2zpl.builder.command
import info.mking.k2zpl.builder.fieldData
import info.mking.k2zpl.builder.fieldSeparator
import info.mking.k2zpl.builder.toZplYesNo
import info.mking.k2zpl.command.options.ZplBarcodeType
import info.mking.k2zpl.command.options.ZplFieldOrientation
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/info/mking/k2zpl/command/FieldSeparator.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 FieldSeparator : ZplCommand {
override val command: CharSequence = "^FS"
}

/**
* Adds a field separator.
*/
fun ZplBuilder.fieldSeparator() {
command(FieldSeparator)
}
25 changes: 25 additions & 0 deletions src/test/kotlin/info/mking/k2zpl/command/FieldSeparatorTest.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 FieldSeparatorTest : DescribeSpec({
isolationMode = IsolationMode.InstancePerLeaf

describe("FieldSeparator") {
it("outputs correct command") {
FieldSeparator.testBuildString() shouldBe "^FS"
}
}
describe("fieldSeparator extension function") {
it("outputs correct command") {
val result = k2zpl {
fieldSeparator()
}
result shouldBe "^FS\n"
}
}
})

0 comments on commit e48c1a1

Please sign in to comment.