MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/buildpacks / TestExtractAngularStartCommand

Function TestExtractAngularStartCommand

pkg/nodejs/angular_test.go:90–140  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestExtractAngularStartCommand(t *testing.T) {
91 testsCases := []struct {
92 name string
93 pjs string
94 want string
95 }{
96 {
97 name: "with angular serve command",
98 pjs: `{
99 "scripts": {
100 "ng": "ng",
101 "start": "ng serve",
102 "build": "ng build",
103 "watch": "ng build --watch --configuration development",
104 "test": "ng test",
105 "serve:ssr:my-angular-app": "node dist/my-angular-app/server/server.mjs"
106 }
107 }`,
108 want: "node dist/my-angular-app/server/server.mjs",
109 },
110 {
111 name: "no angular serve command",
112 pjs: `{
113 "main": "main.js",
114 "scripts": {
115 "start": "node main.js"
116 }
117 }`,
118 want: "",
119 },
120 {
121 name: "no scripts",
122 pjs: `{}`,
123 want: "",
124 },
125 }
126 for _, tc := range testsCases {
127 t.Run(tc.name, func(t *testing.T) {
128 var pjs *PackageJSON = nil
129 if tc.pjs != "" {
130 if err := json.Unmarshal([]byte(tc.pjs), &pjs); err != nil {
131 t.Fatalf("failed to unmarshal package.json: %s, error: %v", tc.pjs, err)
132 }
133 }
134 got := ExtractAngularStartCommand(pjs)
135 if diff := cmp.Diff(tc.want, got); diff != "" {
136 t.Errorf("ExtractAngularStartCommand() mismatch (-want +got):\n%s", diff)
137 }
138 })
139 }
140}

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected