Skip to content

Commit

Permalink
test: @supertape/formatter-progress-bar: env
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jun 4, 2024
1 parent 04a4e47 commit ddeda36
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions packages/formatter-progress-bar/lib/progress-bar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ test('supertape: format: progress bar', async (t) => {
};

const failMessage = 'progress bar: fail';

const {CI} = env;

env.CI = 1;
Expand Down Expand Up @@ -128,7 +127,15 @@ test('supertape: format: progress bar: success', async (t) => {

const message = 'progress bar: success';

env.CI = 1;
const {
CI,
TERMINAL_EMULATOR,
} = env;

updateEnv({
CI: 1,
TERMINAL_EMULATOR: 'JetBrains-JediTerm',
});

const {
run,
Expand All @@ -145,7 +152,10 @@ test('supertape: format: progress bar: success', async (t) => {
run(),
]);

env.CI = 1;
updateEnv({
CI,
TERMINAL_EMULATOR,
});

const expected = montag`
TAP version 13
Expand All @@ -154,7 +164,7 @@ test('supertape: format: progress bar: success', async (t) => {
# tests 1
# pass 1
# ✅ ok
# ✅ ok
` + '\n';

t.equal(result, expected);
Expand Down Expand Up @@ -271,10 +281,15 @@ test('supertape: format: progress bar: color', async (t) => {
};

const message = 'progress-bar: color';
const {SUPERTAPE_PROGRESS_BAR_COLOR} = env;

const {
SUPERTAPE_PROGRESS_BAR_COLOR,
TERMINAL_EMULATOR,
} = env;

updateEnv({
SUPERTAPE_PROGRESS_BAR_COLOR: 'red',
TERMINAL_EMULATOR: undefined,
});

const {
Expand All @@ -294,6 +309,7 @@ test('supertape: format: progress bar: color', async (t) => {

updateEnv({
SUPERTAPE_PROGRESS_BAR_COLOR,
TERMINAL_EMULATOR,
});

const expected = montag`
Expand All @@ -317,10 +333,14 @@ test('supertape: format: progress bar: color: hash', async (t) => {
};

const message = 'progress-bar: color';
const {SUPERTAPE_PROGRESS_BAR_COLOR} = env;
const {
SUPERTAPE_PROGRESS_BAR_COLOR,
TERMINAL_EMULATOR,
} = env;

updateEnv({
SUPERTAPE_PROGRESS_BAR_COLOR: 'undefined',
SUPERTAPE_PROGRESS_BAR_COLOR: undefined,
TERMINAL_EMULATOR: undefined,
});

const {
Expand All @@ -340,6 +360,7 @@ test('supertape: format: progress bar: color: hash', async (t) => {

updateEnv({
SUPERTAPE_PROGRESS_BAR_COLOR,
TERMINAL_EMULATOR,
});

const expected = montag`
Expand All @@ -358,7 +379,6 @@ test('supertape: format: progress bar: color: hash', async (t) => {

test('supertape: format: progress bar: getStream: no SUPERTAPE_PROGRESS_BAR', (t) => {
const {SUPERTAPE_PROGRESS_BAR} = env;

const {_isCI} = global;

global._isCI = 1;
Expand Down Expand Up @@ -527,9 +547,11 @@ test('supertape: format: progress bar: no stack', async (t) => {

function updateEnv(env) {
for (const [name, value] of Object.entries(env)) {
if (value === 'undefined')
delete process.env[name];
else
if (value) {
process.env[name] = value;
continue;
}

delete process.env[name];
}
}

0 comments on commit ddeda36

Please sign in to comment.