
/* lib/terminal/test/samples/simulation - A list of command related tests for running shell simulations against the supported commands. */

import filePathEncode from "../application/browserUtilities/file_path_encode.js";
import vars from "../../utilities/vars.js";

// tests structure
// * artifact - the address of anything written to disk, so that it can be removed
// * command - the command to execute minus the `node js/services` part
// * file - a file system address to open
// * qualifier - how to test, see simulationItem in index.d.ts for appropriate values
// * test - the value to compare against

const // the tsconfig.json file hash used in multiple tests
    base64:string = "ewogICAgImNvbXBpbGVyT3B0aW9ucyI6IHsKICAgICAgICAiYWx3YXlzU3RyaWN0IjogdHJ1ZSwKICAgICAgICAibW9kdWxlIjogIkVTMjAyMCIsCiAgICAgICAgIm1vZHVsZVJlc29sdXRpb24iOiAibm9kZSIsCiAgICAgICAgIm91dERpciI6ICIuL2pzL2xpYiIsCiAgICAgICAgIm5vRW1pdCI6IHRydWUsCiAgICAgICAgIm5vSW1wbGljaXRBbnkiOiB0cnVlLAogICAgICAgICJwcmV0dHkiOiBmYWxzZSwKICAgICAgICAic3RyaWN0RnVuY3Rpb25UeXBlcyI6IHRydWUsCiAgICAgICAgInRhcmdldCI6ICJFUzIwMjAiLAogICAgICAgICJ0eXBlcyI6IFsibm9kZSJdLAogICAgICAgICJ0eXBlUm9vdHMiOiBbIi4vbm9kZV9tb2R1bGVzL0B0eXBlcyJdCiAgICB9LAogICAgImV4Y2x1ZGUiOiBbCiAgICAgICAgImpzIiwKICAgICAgICAibGliL3Rlcm1pbmFsL3Rlc3Qvc3RvcmFnZVRlc3QvdGVtcCIsCiAgICAgICAgIioqL25vZGVfbW9kdWxlcyIsCiAgICAgICAgIioqLy4qLyIKICAgIF0sCiAgICAiaW5jbHVkZSI6IFsKICAgICAgICAiKiovKi50cyIKICAgIF0KfQ==",
    hash:string = "2b519f2492fb40713285995d4cf688d4d24ee1c905b19f8bb39f4ea916f2f760b50f8d176d2a0a18ef3eb2ae2e481806d523d7faac251de23113ae9fb9b26bb0",
    testLocation:string = `${vars.path.project}lib${vars.path.sep}terminal${vars.path.sep}test${vars.path.sep}storageTest${vars.path.sep}temp`,
    md5:string = "7d9c29b30d52f48130ab1a86b6d9e8bf",
    simulation:test_item[] = [
        {
            command: "anUnsupportedCommand",
            qualifier: "contains",
            test: " is not a supported command"
        },
        {
            command: "b",
            qualifier: "is",
            test: `Command '${vars.text.angry}b${vars.text.none}' is ambiguous as it could refer to any of: [${vars.text.cyan}base64, build${vars.text.none}]`
        },
        {
            command: "base64",
            qualifier: "contains",
            test: "No path to encode."
        },
        {
            command: `base64 ${filePathEncode("absolute", "tsconfig.json")}`,
            qualifier: "is",
            test: base64
        },
        {
            //cspell:disable-next-line
            command: "base64 decode string:\"bXkgYmlnIHN0cmluZyBzYW1wbGU=\"",
            qualifier: "is",
            test: "my big string sample"
        },
        {
            command: "base64 decode string:\"ewogICAgImNvbXBpbGVyT3B0aW9ucyI6IHsKICAgICAgICAidGFyZ2V0IjogIkVTNiIsCiAgICAgICAgIm91dERpciI6ICJqcyIKICAgIH0sCiAgICAiaW5jbHVkZSI6IFsKICAgICAgICAiKi50cyIsCiAgICAgICAgIioqLyoudHMiCiAgICBdLAogICAgImV4Y2x1ZGUiOiBbCiAgICAgICAgImpzIiwKICAgICAgICAibm9kZV9tb2R1bGVzIiwKICAgICAgICAidGVzdCIKICAgIF0KfQ==\"",
            qualifier: "ends",
            test: "{\n    \"compilerOptions\": {\n        \"target\": \"ES6\",\n        \"outDir\": \"js\"\n    },\n    \"include\": [\n        \"*.ts\",\n        \"*\u002a/\u002a.ts\"\n    ],\n    \"exclude\": [\n        \"js\",\n        \"node_modules\",\n        \"test\"\n    ]\n}"
        },
        {
            command: "base64 https://duckduckgo.com/assets/logo_homepage.normal.v107.svg",
            qualifier: "is",
            test: " "
        },
        {
            command: "base64 string:\"my big string sample\"",
            qualifier: "is",
            //cspell:disable-next-line
            test: "bXkgYmlnIHN0cmluZyBzYW1wbGU="
        },
        {
            artifact: filePathEncode("absolute", testLocation),
            command: `certificate location:"${testLocation}"`,
            qualifier: "filesystem contains",
            test: filePathEncode("absolute", `${testLocation + vars.path.sep}share-file-ca.crt`)
        },
        {
            artifact: filePathEncode("absolute", testLocation),
            command: `certificate location:"${testLocation}"`,
            qualifier: "filesystem contains",
            test: filePathEncode("absolute", `${testLocation + vars.path.sep}share-file-ca.key`)
        },
        {
            artifact: filePathEncode("absolute", testLocation),
            command: `certificate location:"${testLocation}" server-fileName:"asdf"`,
            qualifier: "filesystem contains",
            test: filePathEncode("absolute", `${testLocation + vars.path.sep}asdf.crt`)
        },
        {
            artifact: filePathEncode("absolute", testLocation),
            command: `certificate location:"${testLocation}" server-fileName:"asdf"`,
            qualifier: "filesystem contains",
            test: filePathEncode("absolute", `${testLocation + vars.path.sep}share-file-ca.key`)
        },
        {
            artifact: filePathEncode("absolute", testLocation),
            command: `certificate location:"${testLocation}" intermediate-fileName:"asdf"`,
            qualifier: "filesystem not contains",
            test: filePathEncode("absolute", `${testLocation + vars.path.sep}share-file-ca.key`)
        },
        {
            command: "comm version",
            qualifier: "contains",
            test: "Prints the current version number and date to the shell."
        },
        {
            command: "commands",
            qualifier: "contains",
            test: `Commands are tested using the ${vars.text.green}test_simulation${vars.text.none} command.`
        },
        {
            command: "commands base64",
            qualifier: "contains",
            test: "base64 encode string:\"my string to encode\""
        },
        {
            command: "commands version",
            qualifier: "contains",
            test: "Prints the current version number and date to the shell."
        },
        {
            command: "copy",
            qualifier: "contains",
            test: "The copy command requires a source path and a destination path."
        },
        {
            command: "copy js",
            qualifier: "contains",
            test: "The copy command requires a source path and a destination path."
        },
        {
            command: `copy ${filePathEncode("absolute", "js")} ${filePathEncode("absolute", testLocation)}`,
            qualifier: "filesystem contains",
            test: filePathEncode("absolute", `${testLocation + vars.path.sep}js${vars.path.sep}lib${vars.path.sep}terminal${vars.path.sep}test${vars.path.sep}samples${vars.path.sep}simulation.js`)
        },
        {
            command: `copy ${filePathEncode("absolute", "js")} ${filePathEncode("absolute", testLocation)}`,
            qualifier: "filesystem contains",
            test: filePathEncode("absolute", `${testLocation + vars.path.sep}js_0${vars.path.sep}lib${vars.path.sep}terminal${vars.path.sep}test${vars.path.sep}samples${vars.path.sep}simulation.js`)
        },
        {
            artifact: filePathEncode("absolute", testLocation),
            command: `copy ${filePathEncode("absolute", "js")} ${filePathEncode("absolute", testLocation)}`,
            file: filePathEncode("absolute", `${testLocation + vars.path.sep}js_1${vars.path.sep}lib${vars.path.sep}terminal${vars.path.sep}test${vars.path.sep}samples${vars.path.sep}simulation.js`),
            qualifier: "file contains",
            test: "import vars from \"../../utilities/vars.js\";"
        },
        {
            command: `directory "${filePathEncode("relative", "./lib/typescript")}" ignore ["node_modules", ".git", ".DS_Store", "src-tauri"] --verbose`,
            qualifier: "contains",
            test: " matching items from address"
        },
        {
            command: `directory ${filePathEncode("absolute", "js")}`,
            qualifier: "contains",
            test: `${filePathEncode("relative", "js/lib/terminal/test/samples/simulation.js", true)}","file"`
        },
        {
            command: `directory ${filePathEncode("absolute", "js")} 2`,
            qualifier: "contains",
            test: "lib\",\"directory\",\"\",0,6,"
        },
        {
            command: `directory ${filePathEncode("absolute", "js")} ignore ["test", "src-tauri"]`,
            qualifier: "not contains",
            test: `${filePathEncode("relative", "js/test/samples/simulation.js")}"`
        },
        {
            command: `directory ${filePathEncode("absolute", "js")} array`,
            qualifier: "not contains",
            test: "lib\",\"directory\",\"\",0,6,"
        },
        {
            command: `directory ${filePathEncode("absolute", "")} array depth:1`,
            qualifier: "not contains",
            test: filePathEncode("relative", "bin/spaces")
        },
        {
            command: `directory ${filePathEncode("absolute", "")} list depth:1`,
            qualifier: "contains",
            test: `file        34,085  ${filePathEncode("absolute", "license")}`
        },
        {
            command: `directory ${filePathEncode("absolute", "")} list relative depth:1`,
            qualifier: "contains",
            test: "file        34,085  license"
        },
        {
            command: `directory ${filePathEncode("absolute", "js")} typeof`,
            qualifier: "is",
            test: "directory"
        },
        {
            command: `directory ${filePathEncode("absolute", "tsconfig.json")} hash`,
            qualifier: "contains",
            test: `[["${filePathEncode("absolute", "tsconfig.json")}","file","${hash}",0,0,null,""]]`
        },
        {
            command: `directory typeof ${filePathEncode("absolute", "js")}`,
            qualifier: "is",
            test: "directory"
        },
        {
            command: `directory typeof ${filePathEncode("absolute", "js/lib/terminal/test/samples/simulation.js")}`,
            qualifier: "is",
            test: "file"
        },
        {
            command: "get",
            qualifier: "contains",
            test: "The get command requires an address and that address must be in http/https scheme."
        },
        {
            command: "get notAnAddress",
            qualifier: "contains",
            test: "The get command requires an address in http/https scheme."
        },
        {
            command: "get https://duckduckgo.com/",
            qualifier: "contains",
            test: "<title>DuckDuckGo — Privacy, simplified.</title>"
        },
        {
            command: "hash",
            qualifier: "contains",
            test: `Command ${vars.text.cyan}hash${vars.text.none} requires some form of address of something to analyze, ${vars.text.angry}but no address is provided${vars.text.none}.`
        },
        {
            command: "hash anUnsupportedPath",
            qualifier: "contains",
            test: `${filePathEncode("relative", "/anUnsupportedPath") + vars.text.none} is not a file or directory.`
        },
        {
            command: `hash ${filePathEncode("absolute", "tsconfig.json")}`,
            qualifier: "is",
            test: hash
        },
        {
            command: `hash ${filePathEncode("absolute", "tsconfig.json")} md5`,
            qualifier: "is",
            test: md5
        },
        {
            command: "hash string:tsconfig.json md5",
            qualifier: "is",
            test: "e5e546dd2eb0351f813d63d1b39dbc48"
        },
        {
            command: "hash string:tsconfig.json shake256",
            qualifier: "is",
            test: "9a3e06cfa3f81d2e3e02957d1f573194987440206ceab8ad5456bfd0316cd2b9"
        },
        {
            command: `hash ${filePathEncode("absolute", "tsconfig.json")} --verbose`,
            qualifier: "contains",
            test: "seconds total time"
        },
        {
            command: `hash ${filePathEncode("absolute", "")} list ignore ["node_modules", ".git", "js", "lib", "src-tauri"]`,
            qualifier: "contains",
            test: `tsconfig.json:${hash}`
        },
        {
            command: `hash ${filePathEncode("absolute", "")} list ignore [.git, "node_modules", "js", "lib", "src-tauri", "space test"]`,
            qualifier: "contains",
            test: `tsconfig.json:${hash}`
        },
        {
            command: `hash ${filePathEncode("absolute", "")} list ignore [.git, "node_modules", "js", "lib", "src-tauri", "space test"]`,
            qualifier: "not contains",
            test: filePathEncode("relative", "js/lib")
        },
        {
            command: "hash https://duckduckgo.com/assets/logo_homepage.normal.v107.svg",
            qualifier: "is",
            test: "0627f9ecca62cca0c9796ff1c1f5c4b50efdcf796c3d0a4ad26b38e135b56243a72bf253f1ed791996425ad70ccf1d0f42d733b1000cb8636a074f4f2e1dc089"
        },
        {
            command: "help",
            qualifier: "contains",
            test: `To see every command example use the '${vars.text.cyan}all${vars.text.none}' argument:`
        },
        {
            command: "help 2",
            qualifier: "contains",
            test: `Commands are tested using the ${vars.text.green}test_simulation${vars.text.none} command.`
        },
        {
            command: "help 3",
            qualifier: "ends",
            test: `share commands no_color hash${vars.text.none}`
        },
        {
            command: `lint ${filePathEncode("absolute", "lib/terminal/test/application/simulation.ts")}`,
            qualifier: "contains",
            test: `${vars.text.green}Lint complete${vars.text.none} for ${vars.text.cyan + vars.text.bold + filePathEncode("absolute", "lib/terminal/test/application/simulation.ts") + vars.text.none}`
        },
        {
            command: `lint ${filePathEncode("absolute", "js/lib/terminal/test/application/simulation.js")}`,
            qualifier: "contains",
            test: "Lint command not configured to work with JavaScript files."
        },
        {
            command: `lint ${filePathEncode("relative", "./js")}`,
            qualifier: "contains",
            test: "Lint command not configured to work with JavaScript files."
        },
        {
            command: `mkdir ${filePathEncode("absolute", "lib/terminal/test/testDir")} --verbose`,
            qualifier: "contains",
            test: `Directory created at ${vars.text.cyan + filePathEncode("absolute", "lib/terminal/test/testDir") + vars.text.none}`
        },
        {
            command: `remove ${filePathEncode("absolute", "lib/terminal/test/testDir")} --verbose`,
            qualifier: "contains",
            test: `${vars.environment.name} removed ${vars.text.angry}1${vars.text.none} directory, ${vars.text.angry}0${vars.text.none} file, ${vars.text.angry}0${vars.text.none} symbolic links at ${vars.text.angry}0${vars.text.none} bytes.`
        },
        {
            command: `mkdir ${filePathEncode("absolute", "lib/terminal/test/testDir")}`,
            qualifier: "is",
            test: ""
        },
        {
            command: `remove ${filePathEncode("absolute", "lib/terminal/test/testDir")}`,
            qualifier: "is",
            test: ""
        },
        {
            command: "version 1",
            qualifier: "contains",
            test: `Version ${vars.text.angry}`
        },
        {
            command: "version 2",
            qualifier: "begins",
            test: `${vars.text.cyan + vars.text.bold + vars.text.underline + vars.environment.name} - Version${vars.text.none}`
        },
        {
            command: "version 3",
            qualifier: "contains",
            test: `git Log ${vars.text.cyan}`
        }
    ];

export default simulation;