Skip to content

Commit

Permalink
test(cli): update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaslz committed Jan 28, 2024
1 parent 61fb0df commit 1195e49
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 48 deletions.
18 changes: 9 additions & 9 deletions packages/cli/src/__snapshots__/on-list-action.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ exports[`Actions - onListAction > list domains availables 1`] = `
"calls": [
[
"
[90m┌──────────────────────────────────────[39m[90m┬───────────────────────[39m[90m┬───────────────────────────────[39m[90m┬───────────[39m[90m┬──────[39m[90m┬──────┐[39m
[90m│[39m[31m id [39m[90m│[39m[31m key [39m[90m│[39m[31m domains [39m[90m│[39m[31m location [39m[90m│[39m[31m port [39m[90m│[39m[31m ping [39m[90m│[39m
[90m├──────────────────────────────────────[39m[90m┼───────────────────────[39m[90m┼───────────────────────────────[39m[90m┼───────────[39m[90m┼──────[39m[90m┼──────┤[39m
[90m│[39m d7274462-e2cc-4ed3-8b07-fea3e342e7aa [90m│[39m local.some-domain.tld [90m│[39m https://local.some-domain.tld [90m│[39m [90m│[39m [90m│[39m [90m│[39m
[90m├──────────────────────────────────────[39m[90m┼───────────────────────[39m[90m┼───────────────────────────────[39m[90m┼───────────[39m[90m┼──────[39m[90m┼──────┤[39m
[90m│[39m [90m│[39m [90m│[39m [90m│[39m / [90m│[39m 3333 [90m│[39m 200 [90m│[39m
[90m├──────────────────────────────────────[39m[90m┼───────────────────────[39m[90m┼───────────────────────────────[39m[90m┼───────────[39m[90m┼──────[39m[90m┼──────┤[39m
[90m│[39m [90m│[39m [90m│[39m [90m│[39m /app-name [90m│[39m 3000 [90m│[39m 404 [90m│[39m
[90m└──────────────────────────────────────[39m[90m┴───────────────────────[39m[90m┴───────────────────────────────[39m[90m┴───────────[39m[90m┴──────[39m[90m┴──────┘[39m
┌──────────────────────────────────────┬───────────────────────┬───────────────────────────────┬───────────┬──────┬──────
id key domains location port ping
├──────────────────────────────────────┼───────────────────────┼───────────────────────────────┼───────────┼──────┼──────┤
d7274462-e2cc-4ed3-8b07-fea3e342e7aa local.some-domain.tld https://local.some-domain.tld
├──────────────────────────────────────┼───────────────────────┼───────────────────────────────┼───────────┼──────┼──────┤
/ 3333 200
├──────────────────────────────────────┼───────────────────────┼───────────────────────────────┼───────────┼──────┼──────┤
/app-name 3000 404
└──────────────────────────────────────┴───────────────────────┴───────────────────────────────┴───────────┴──────┴──────┘
",
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ exports[`Utils - generateProxyImage > success > multiple service > create domain
"calls": [
[
"
[90m┌──────────────────[39m[90m┬─────────────┐[39m
[90m│[39m[31m domain [39m[90m│[39m[31m app running [39m[90m│[39m
[90m├──────────────────[39m[90m┼─────────────┤[39m
[90m│[39m https://demo.com [90m│[39m no [90m│[39m
[90m└──────────────────[39m[90m┴─────────────┘[39m
┌──────────────────┬─────────────
domain app running
├──────────────────┼─────────────┤
https://demo.com no
└──────────────────┴─────────────┘
",
],
],
Expand Down Expand Up @@ -311,11 +311,11 @@ exports[`Utils - generateProxyImage > success > multiple service > create domain
"calls": [
[
"
[90m┌──────────────────[39m[90m┬─────────────┐[39m
[90m│[39m[31m domain [39m[90m│[39m[31m app running [39m[90m│[39m
[90m├──────────────────[39m[90m┼─────────────┤[39m
[90m│[39m https://demo.com [90m│[39m no [90m│[39m
[90m└──────────────────[39m[90m┴─────────────┘[39m
┌──────────────────┬─────────────
domain app running
├──────────────────┼─────────────┤
https://demo.com no
└──────────────────┴─────────────┘
",
],
],
Expand Down Expand Up @@ -475,11 +475,11 @@ exports[`Utils - generateProxyImage > success > multiple service > does not exis
"calls": [
[
"
[90m┌──────────────────[39m[90m┬─────────────┐[39m
[90m│[39m[31m domain [39m[90m│[39m[31m app running [39m[90m│[39m
[90m├──────────────────[39m[90m┼─────────────┤[39m
[90m│[39m https://demo.com [90m│[39m no [90m│[39m
[90m└──────────────────[39m[90m┴─────────────┘[39m
┌──────────────────┬─────────────
domain app running
├──────────────────┼─────────────┤
https://demo.com no
└──────────────────┴─────────────┘
",
],
],
Expand Down Expand Up @@ -615,11 +615,11 @@ exports[`Utils - generateProxyImage > success > single service > create domain c
"calls": [
[
"
[90m┌──────────────────[39m[90m┬─────────────┐[39m
[90m│[39m[31m domain [39m[90m│[39m[31m app running [39m[90m│[39m
[90m├──────────────────[39m[90m┼─────────────┤[39m
[90m│[39m https://demo.com [90m│[39m no [90m│[39m
[90m└──────────────────[39m[90m┴─────────────┘[39m
┌──────────────────┬─────────────
domain app running
├──────────────────┼─────────────┤
https://demo.com no
└──────────────────┴─────────────┘
",
],
],
Expand Down Expand Up @@ -755,11 +755,11 @@ exports[`Utils - generateProxyImage > success > single service > create domain c
"calls": [
[
"
[90m┌──────────────────[39m[90m┬─────────────┐[39m
[90m│[39m[31m domain [39m[90m│[39m[31m app running [39m[90m│[39m
[90m├──────────────────[39m[90m┼─────────────┤[39m
[90m│[39m https://demo.com [90m│[39m no [90m│[39m
[90m└──────────────────[39m[90m┴─────────────┘[39m
┌──────────────────┬─────────────
domain app running
├──────────────────┼─────────────┤
https://demo.com no
└──────────────────┴─────────────┘
",
],
],
Expand Down Expand Up @@ -895,11 +895,11 @@ exports[`Utils - generateProxyImage > success > single service > does not exists
"calls": [
[
"
[90m┌────────────────────[39m[90m┬─────────────┐[39m
[90m│[39m[31m domain [39m[90m│[39m[31m app running [39m[90m│[39m
[90m├────────────────────[39m[90m┼─────────────┤[39m
[90m│[39m https://domain.tld [90m│[39m no [90m│[39m
[90m└────────────────────[39m[90m┴─────────────┘[39m
┌────────────────────┬─────────────
domain app running
├────────────────────┼─────────────┤
https://domain.tld no
└────────────────────┴─────────────┘
",
],
],
Expand Down
18 changes: 9 additions & 9 deletions packages/cli/src/utils/__snapshots__/list-configs.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ exports[`Utils - listConfigs > list configs 1`] = `
"calls": [
[
"
[90m┌──────────────────────────────────────[39m[90m┬───────────────────────[39m[90m┬───────────────────────────────[39m[90m┬───────────[39m[90m┬──────[39m[90m┬──────┐[39m
[90m│[39m[31m id [39m[90m│[39m[31m key [39m[90m│[39m[31m domains [39m[90m│[39m[31m location [39m[90m│[39m[31m port [39m[90m│[39m[31m ping [39m[90m│[39m
[90m├──────────────────────────────────────[39m[90m┼───────────────────────[39m[90m┼───────────────────────────────[39m[90m┼───────────[39m[90m┼──────[39m[90m┼──────┤[39m
[90m│[39m d7274462-e2cc-4ed3-8b07-fea3e342e7aa [90m│[39m local.some-domain.tld [90m│[39m https://local.some-domain.tld [90m│[39m [90m│[39m [90m│[39m [90m│[39m
[90m├──────────────────────────────────────[39m[90m┼───────────────────────[39m[90m┼───────────────────────────────[39m[90m┼───────────[39m[90m┼──────[39m[90m┼──────┤[39m
[90m│[39m [90m│[39m [90m│[39m [90m│[39m / [90m│[39m 3333 [90m│[39m 200 [90m│[39m
[90m├──────────────────────────────────────[39m[90m┼───────────────────────[39m[90m┼───────────────────────────────[39m[90m┼───────────[39m[90m┼──────[39m[90m┼──────┤[39m
[90m│[39m [90m│[39m [90m│[39m [90m│[39m /app-name [90m│[39m 3000 [90m│[39m 200 [90m│[39m
[90m└──────────────────────────────────────[39m[90m┴───────────────────────[39m[90m┴───────────────────────────────[39m[90m┴───────────[39m[90m┴──────[39m[90m┴──────┘[39m
┌──────────────────────────────────────┬───────────────────────┬───────────────────────────────┬───────────┬──────┬──────
id key domains location port ping
├──────────────────────────────────────┼───────────────────────┼───────────────────────────────┼───────────┼──────┼──────┤
d7274462-e2cc-4ed3-8b07-fea3e342e7aa local.some-domain.tld https://local.some-domain.tld
├──────────────────────────────────────┼───────────────────────┼───────────────────────────────┼───────────┼──────┼──────┤
/ 3333 200
├──────────────────────────────────────┼───────────────────────┼───────────────────────────────┼───────────┼──────┼──────┤
/app-name 3000 200
└──────────────────────────────────────┴───────────────────────┴───────────────────────────────┴───────────┴──────┴──────┘
",
],
],
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/src/utils/generate-proxy-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ const distPath = path.resolve(__dirname, "./");
const rootPath = `${distPath}/.local-ssl-management`;
const sslPath = `${rootPath}/ssl`;

const isTest = process.env.NODE_ENV === "test";

const renderTable = (config: Config[]) => {
const tablePing = new Table({
head: ["domain", "app running"],
...(isTest
? {
style: {
head: [], //disable colors in header cells
border: [], //disable colors for the border
},
}
: {}),
});

config.forEach((c: Config) => {
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/src/utils/list-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ import type { Config } from "@dimaslz/local-ssl-management-core";
import Table from "cli-table3";
import shell from "shelljs";

const isTest = process.env.NODE_ENV === "test";

export const listConfigs = (config: Config[]) => {
const table = new Table({
head: ["id", "key", "domains", "location", "port", "ping"],
...(isTest
? {
style: {
head: [], //disable colors in header cells
border: [], //disable colors for the border
},
}
: {}),
});

config.forEach(({ id, domain, services }) => {
Expand Down

0 comments on commit 1195e49

Please sign in to comment.