Exemple #1
0
func TestTypeScript(t *testing.T) {
	bin := os.Getenv("STATIX_TEST_TYPESCRIPT_BIN")

	if bin == "" {
		t.Skip("STATIX_TEST_TYPESCRIPT_BIN is not set")
	}

	s := resource.NewString("class Test{}")
	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;
})();
`

	if !bytes.Equal(content, []byte(expected)) {
		t.Error("content dumped is not correct", string(content))
	}
}
Exemple #2
0
func TestUglifyJs(t *testing.T) {
	bin := os.Getenv("STATIX_TEST_UGLIFYJS_BIN")

	if bin == "" {
		t.Skip("STATIX_TEST_UGLIFYJS_BIN is not set")
	}

	s := resource.NewString(" console.log( \"ok\" ) ;")
	a := NewUglifyJs(bin)

	r, err := a.Alter(s)

	if err != nil {
		t.Error("could not alter resource")
	}

	content, err := r.Dump()

	if err != nil {
		t.Error("could not dump content")
	}

	expected := "console.log(\"ok\");"

	if !bytes.Equal(content, []byte(expected)) {
		t.Error("content dumped is not correct", string(content))
	}
}
Exemple #3
0
func TestStylus(t *testing.T) {
	bin := os.Getenv("STATIX_TEST_STYLUS_BIN")

	if bin == "" {
		t.Skip("STATIX_TEST_STYLUS_BIN is not set")
	}

	s := resource.NewString(`
			html
				color red
	`)
	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))
	}
}
Exemple #4
0
func getManagerTest() Manager {
	return Manager{
		Input:  "./tests/in",
		Output: "./tests/out",
		Server: Server{
			Directory: ".",
			URL:       "http://www.example.com/static",
		},
		Filters: []Filter{
			{
				Alteration: ReverseAlteration{},
				Pattern:    NewExtensionPattern("ext"),
			},
		},
		Assets: map[string]Asset{
			"pack": AssetPack{
				Input:  "dirIn",
				Output: "dirOut",
			},
			"single": SingleAsset{
				Output: "single.ext",
				Input:  resource.NewString("single"),
			},
		},
	}
}