mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-08-24 21:17:31 +00:00
29 lines
624 B
Go
29 lines
624 B
Go
//go:build !exclude_frontend
|
|
|
|
package frontend
|
|
|
|
import (
|
|
"testing"
|
|
"testing/fstest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestIsSPARequest(t *testing.T) {
|
|
distFS := fstest.MapFS{
|
|
"assets/app.js": &fstest.MapFile{Data: []byte("console.log('test')")},
|
|
}
|
|
|
|
t.Run("root path is spa request", func(t *testing.T) {
|
|
assert.True(t, isSPARequest("", distFS))
|
|
})
|
|
|
|
t.Run("existing bundled asset is not spa request", func(t *testing.T) {
|
|
assert.False(t, isSPARequest("assets/app.js", distFS))
|
|
})
|
|
|
|
t.Run("unknown path is spa request", func(t *testing.T) {
|
|
assert.True(t, isSPARequest("authorize", distFS))
|
|
})
|
|
}
|