time_test.go 375 B

1234567891011121314151617181920
  1. package jsc_test
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/sagernet/sing-box/script/jsc"
  6. "github.com/dop251/goja"
  7. "github.com/stretchr/testify/require"
  8. )
  9. func TestTimeToValue(t *testing.T) {
  10. t.Parallel()
  11. runtime := goja.New()
  12. now := time.Now()
  13. err := runtime.Set("now", jsc.TimeToValue(runtime, now))
  14. require.NoError(t, err)
  15. println(runtime.Get("now").String())
  16. }