Skip to content

Commit

Permalink
Add test & change cli description
Browse files Browse the repository at this point in the history
  • Loading branch information
boogeroccam committed Feb 14, 2024
1 parent d88d161 commit c1352fc
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/termsvg/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Cmd struct {
File string `arg:"" type:"existingfile" help:"asciicast file to export"`
Output string `optional:"" short:"o" type:"path" help:"where to save the file. Defaults to <input_file>.svg"`
Mini bool `name:"minify" optional:"" short:"m" help:"minify output file. May be slower"`
NoWindow bool `name:"nowindow" optional:"" short:"n" help:"create window in svg"`
NoWindow bool `name:"nowindow" optional:"" short:"n" help:"don't render terminal window in svg"`
BackgroundColor string `optional:"" short:"b" help:"background color in hexadecimal format (e.g. #FFFFFF)"`
TextColor string `optional:"" short:"t" help:"text color in hexadecimal format (e.g. #000000)"`
}
Expand Down
17 changes: 17 additions & 0 deletions internal/svg/svg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ func TestExport(t *testing.T) {
g.Assert(t, "TestExportOutput", output.Bytes())
}

func TestNoWindow(t *testing.T) {
input := testutils.GoldenData(t, "TestExportInput")

cast, err := asciicast.Unmarshal(input)
if err != nil {
t.Fatal(err)
}

var output bytes.Buffer

// Pass empty override bg and text colors
svg.Export(*cast, &output, "", "", true)

g := goldie.New(t)
g.Assert(t, "TestExportOutputNoWindow", output.Bytes())
}

func BenchmarkExport(b *testing.B) {
input := testutils.GoldenData(b, "TestExportInput")

Expand Down
31 changes: 31 additions & 0 deletions internal/svg/testdata/TestExportOutputNoWindow.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<!-- Generated by SVGo -->
<svg width="2596" height="1510"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="0" y="0" width="2596" height="1510" style="fill:#282d35" />
<g transform="translate(20,30)" >
<g style="animation-duration:3.35s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end);font-family:Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;font-size:20px">
<style type="text/css">
<![CDATA[
@keyframes k {79.807%{transform:translateX(-0px)}82.298%{transform:translateX(-2596px)}87.777%{transform:translateX(-5192px)}92.767%{transform:translateX(-7788px)}100.000%{transform:translateX(-10384px)}}.a{fill:#e5e5e5}
]]>
</style>
<g transform="translate(0)">
<text x="0" y="0" class="a" >h</text>
</g>
<g transform="translate(2596)">
<text x="0" y="0" class="a" >he</text>
</g>
<g transform="translate(5192)">
<text x="0" y="0" class="a" >hel</text>
</g>
<g transform="translate(7788)">
<text x="0" y="0" class="a" >hell</text>
</g>
<g transform="translate(10384)">
<text x="0" y="0" class="a" >hello</text>
</g>
</g>
</g>
</svg>

0 comments on commit c1352fc

Please sign in to comment.