-
Notifications
You must be signed in to change notification settings - Fork 43
/
js_test.go
39 lines (34 loc) · 1.24 KB
/
js_test.go
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
package gowd
import (
"bytes"
"io"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestExecJSNow(t *testing.T) {
var buf bytes.Buffer
Output = io.Writer(&buf)
ExecJSNow("alert('this is all the testing possible without running NWJS, hope itl do')")
assert.Equal(t, "$alert('this is all the testing possible without running NWJS, hope itl do')"+"\n", buf.String())
}
func TestExecJS(t *testing.T) {
var buf bytes.Buffer
Output = io.Writer(&buf)
ExecJS("alert('this is all the testing possible without running NWJS, hope itl do')")
elem := NewElement("hello world")
elem.SetID("_hello world1")
render(elem, Output)
assert.Equal(t, `<hello world id="_hello world1"></hello world>`+"\n"+`$alert('this is all the testing possible without running NWJS, hope itl do')`+"\n", buf.String())
Output = os.Stdout
}
func TestAlert(t *testing.T) {
var buf bytes.Buffer
Output = io.Writer(&buf)
Alert("this is all the testing possible without running NWJS, hope itl do'")
elem := NewElement("hello world")
elem.SetID("_hello world1")
render(elem, Output)
assert.Equal(t, "$alert(\"this is all the testing possible without running NWJS, hope itl do'\");\n<hello world id=\"_hello world1\"></hello world>\n", buf.String())
Output = os.Stdout
}