-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update MediaMode handling to use correct values, replace with ZplYesN…
…o, add tests
- Loading branch information
1 parent
96a77f9
commit 7f60a6e
Showing
5 changed files
with
73 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
package info.mking.k2zpl.command | ||
|
||
import info.mking.k2zpl.builder.ZplBuilder | ||
import info.mking.k2zpl.builder.command | ||
import info.mking.k2zpl.builder.toZplYesNo | ||
import info.mking.k2zpl.command.options.ZplMediaMode | ||
import info.mking.k2zpl.command.options.ZplPreprintedLabelHandling | ||
import info.mking.k2zpl.command.options.ZplYesNo | ||
|
||
internal data class MediaMode(val mediaMode: ZplMediaMode, val preprintedLabelHandling: ZplPreprintedLabelHandling) : | ||
ZplCommand { | ||
internal data class MediaMode( | ||
val mediaMode: ZplMediaMode, | ||
val prePeelSelect: ZplYesNo | ||
) : ZplCommand { | ||
override val command: CharSequence = "^MM" | ||
override val parameters: LinkedHashMap<CharSequence, Any?> = | ||
linkedMapOf("mode" to mediaMode.value, "preprinted" to preprintedLabelHandling.value) | ||
linkedMapOf("m" to mediaMode.value, "p" to prePeelSelect) | ||
} | ||
|
||
/** | ||
* Sets Media Mode | ||
*/ | ||
fun ZplBuilder.mediaMode( | ||
mediaMode: ZplMediaMode, | ||
prePeel: Boolean = false | ||
) { | ||
command( | ||
MediaMode( | ||
mediaMode = mediaMode, | ||
prePeelSelect = prePeel.toZplYesNo() | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/main/kotlin/info/mking/k2zpl/command/options/ZplPreprintedLabelHandling.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package info.mking.k2zpl.command | ||
|
||
import info.mking.k2zpl.command.options.ZplMediaMode | ||
import info.mking.k2zpl.command.options.ZplYesNo | ||
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 MediaModeTest : DescribeSpec({ | ||
isolationMode = IsolationMode.InstancePerLeaf | ||
|
||
val mediaMode = MediaMode(mediaMode = ZplMediaMode.CUTTER, prePeelSelect = ZplYesNo.NO) | ||
|
||
describe("MediaMode") { | ||
it("outputs correct command") { | ||
mediaMode.testBuildString() shouldBe "^MMC,N" | ||
} | ||
it("uses mediaMode parameter properly") { | ||
ZplMediaMode.entries.forEach { | ||
mediaMode.copy(mediaMode = it).testBuildString() shouldBe "^MM${it.value},N" | ||
} | ||
} | ||
it("uses prePeelSelect parameter properly") { | ||
ZplYesNo.entries.forEach { | ||
mediaMode.copy(prePeelSelect = it).testBuildString() shouldBe "^MMC,${it}" | ||
} | ||
} | ||
} | ||
describe("mediaMode extension function") { | ||
it("outputs correct command") { | ||
val result = k2zpl { | ||
mediaMode(mediaMode = ZplMediaMode.DELAYED_CUT, prePeel = true) | ||
} | ||
result shouldBe "^MMD,Y\n" | ||
} | ||
it("uses default values") { | ||
val result = k2zpl { | ||
mediaMode(mediaMode = ZplMediaMode.REWIND) | ||
} | ||
result shouldBe "^MMR,N\n" | ||
} | ||
} | ||
}) |