File: compiler_test.go

package info (click to toggle)
golang-github-wellington-go-libsass 0.9.2%2Bgit20181130.4ef5b9d-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,128 kB
  • sloc: cpp: 28,607; ansic: 839; makefile: 44
file content (73 lines) | stat: -rw-r--r-- 1,067 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package libsass

import (
	"bytes"
	"log"
	"os"
	"testing"
)

func ExampleCompiler_stdin() {

	src := bytes.NewBufferString(`div { p { color: red; } }`)

	comp, err := New(os.Stdout, src)
	if err != nil {
		log.Fatal(err)
	}
	err = comp.Run()
	if err != nil {
		log.Fatal(err)
	}

	// Output:
	// div p {
	//   color: red; }
	//

}

func ExampleComipler_sass() {
	src := bytes.NewBufferString(`
html
  font-family: 'MonoSocial'
`)
	comp, err := New(os.Stdout, src, WithSyntax(SassSyntax))
	if err != nil {
		log.Fatal(err)
	}
	err = comp.Run()
	if err != nil {
		log.Fatal(err)
	}

	// Output:
	// html {
	//   font-family: 'MonoSocial'; }

}

func TestCompiler_path(t *testing.T) {
	var dst bytes.Buffer

	comp, err := New(&dst, nil, Path("test/scss/basic.scss"))
	if err != nil {
		t.Fatal(err)
	}
	err = comp.Run()
	if err != nil {
		t.Fatal(err)
	}

	e := `div p {
  color: red; }
`
	if e != dst.String() {
		t.Errorf("got: %s wanted: %s", dst.String(), e)
	}

	if e := 1; len(comp.Imports()) != e {
		t.Errorf("got: %d wanted: %d", len(comp.Imports()), e)
	}

}