Files
wehub-resource-sync a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

45 lines
1.4 KiB
Go

package resolver
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zzet/gortex/internal/graph"
)
func TestResolveNgRxEffects(t *testing.T) {
g := graph.New()
g.AddNode(&graph.Node{
ID: "effects.ts::UserEffects.loadUsers$", Kind: graph.KindVariable, Name: "loadUsers$",
FilePath: "effects.ts", Language: "typescript", Meta: map[string]any{"ngrx_effect": "loadUsers$"},
})
g.AddNode(&graph.Node{
ID: "actions.ts::LoadUsers", Kind: graph.KindConstant, Name: "LoadUsers",
FilePath: "actions.ts", Language: "typescript",
})
g.AddEdge(&graph.Edge{
From: "effects.ts::UserEffects.loadUsers$", To: "unresolved::*.LoadUsers", Kind: graph.EdgeCalls,
FilePath: "effects.ts", Meta: map[string]any{"via": "ngrx-effect", "ngrx_action": "LoadUsers"},
})
n := ResolveNgRxEffects(g)
assert.Equal(t, 1, n, "one effect placeholder should resolve")
var found *graph.Edge
for _, e := range g.GetOutEdges("effects.ts::UserEffects.loadUsers$") {
if e.Kind == graph.EdgeCalls && e.To == "actions.ts::LoadUsers" {
found = e
}
}
require.NotNil(t, found, "effect should resolve to the LoadUsers action node")
assert.Equal(t, SynthNgRxEffect, found.Meta[MetaSynthesizedBy])
}
func TestResolveNgRxEffects_NoEffectsIsNoOp(t *testing.T) {
g := graph.New()
g.AddNode(&graph.Node{ID: "a.ts::x", Kind: graph.KindFunction, Name: "x", FilePath: "a.ts"})
assert.Equal(t, 0, ResolveNgRxEffects(g))
}