|
| 1 | +/* |
| 2 | + * Copyright 2022 The Kubernetes Authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import doPlan from "../plan" |
| 18 | +import Input, { Tree } from "../Input" |
| 19 | +import { importd } from "./1.spec" |
| 20 | + |
| 21 | +const filename = "guidebook-tree-model6.md" |
| 22 | + |
| 23 | +const messageForMacOS = "echo MMM" |
| 24 | +const messageForLinux = "echo LLL" |
| 25 | +const messageForWindows = "echo WWW" |
| 26 | + |
| 27 | +const messageForElectron = |
| 28 | + process.platform === "linux" ? messageForLinux : process.platform === "darwin" ? messageForMacOS : messageForWindows |
| 29 | + |
| 30 | +// here, we will squash away the choice |
| 31 | +const importgForElectron: (name: string) => Tree = (name: string) => ({ |
| 32 | + name, |
| 33 | + children: [{ name: messageForElectron }], |
| 34 | +}) |
| 35 | + |
| 36 | +// here, we won't squash away the choice |
| 37 | +const importgForBrowser: (name: string) => Tree = (name: string) => ({ |
| 38 | + name, |
| 39 | + children: [ |
| 40 | + { name: "Option 1: MacOS", children: [{ name: messageForMacOS }] }, |
| 41 | + { name: "Option 2: Linux", children: [{ name: messageForLinux }] }, |
| 42 | + { name: "Option 3: Windows", children: [{ name: messageForWindows }] }, |
| 43 | + ], |
| 44 | +}) |
| 45 | + |
| 46 | +export const importg: (name?: string) => Tree = (name = "importg.md") => |
| 47 | + (process.env.MOCHA_RUN_TARGET || "electron") === "electron" ? importgForElectron(name) : importgForBrowser(name) |
| 48 | + |
| 49 | +const tree: Input["tree"] = () => [ |
| 50 | + { |
| 51 | + name: "Sequence", |
| 52 | + children: [importg(), importd], |
| 53 | + }, |
| 54 | +] |
| 55 | + |
| 56 | +const IN6: Input = { |
| 57 | + input: filename, |
| 58 | + tree, |
| 59 | +} |
| 60 | + |
| 61 | +doPlan(IN6) |
0 commit comments