func TestJepgOptim(t *testing.T) { bin := os.Getenv("STATIX_TEST_JPEGOPTIM_BIN") if bin == "" { t.Skip("STATIX_TEST_JPEGOPTIM_BIN is not set") } input := resource.NewFile("testFiles/test.jpg") a := NewJpegOptim(bin, true, 70) output, err := a.Alter(input) if err != nil { t.Error("could not alter resource") } outputBytes, err := output.Dump() if err != nil { t.Error("could not dump content") } inputBytes, _ := input.Dump() if len(inputBytes) < len(outputBytes) { t.Error("resource has not been optimized") } }
func TestTypeScriptFile(t *testing.T) { bin := os.Getenv("STATIX_TEST_TYPESCRIPT_BIN") if bin == "" { t.Skip("STATIX_TEST_TYPESCRIPT_BIN is not set") } s := resource.NewFile("./testFiles/test-main.ts") a := NewTypeScript(bin) r, err := a.Alter(s) if err != nil { t.Error("could not alter resource", err.Error()) } content, err := r.Dump() if err != nil { t.Error("could not dump content") } expected := `var Test = (function () { function Test() { } return Test; })(); /// <reference path="./test-ref.ts"/> ` if !bytes.Equal(content, []byte(expected)) { t.Error("content dumped is not correct", string(content)) } }
func TestStylusFile(t *testing.T) { bin := os.Getenv("STATIX_TEST_STYLUS_BIN") if bin == "" { t.Skip("STATIX_TEST_STYLUS_BIN is not set") } s := resource.NewFile("./testFiles/test-main.styl") a := NewStylus(bin) r, err := a.Alter(s) if err != nil { t.Error("could not alter resource", err.Error()) } content, err := r.Dump() if err != nil { t.Error("could not dump content") } expected := `html { color: #f00; } ` if !bytes.Equal(content, []byte(expected)) { t.Error("content dumped is not correct", string(content)) } }