Skip to content

Commit

Permalink
Refactor config.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Sep 9, 2021
1 parent c4560dd commit 19a0187
Showing 1 changed file with 14 additions and 48 deletions.
62 changes: 14 additions & 48 deletions __tests__/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,18 @@
import * as config from '../src/config';

describe('Config tests', () => {
it('checking addINIValuesOnWindows', async () => {
let win32: string = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'win32'
);
expect(win32).toContain(
'Add-Content "$php_dir\\php.ini" "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata"'
);

win32 = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'openbsd'
);
expect(win32).toContain('Platform openbsd is not supported');
});

it('checking addINIValuesOnLinux', async () => {
let linux: string = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'linux',
true
);
expect(linux).toContain(
'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'
);

linux = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'openbsd'
);
expect(linux).toContain('Platform openbsd is not supported');
});

it('checking addINIValuesOnDarwin', async () => {
let darwin: string = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'darwin'
);
expect(darwin).toContain(
'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'
);

darwin = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'openbsd'
);
expect(darwin).toContain('Platform openbsd is not supported');
});
it.each`
ini_values | os_version | output
${'a=b, c=d'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b\nc=d"'}
${'a=b, c=d'} | ${'linux'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
${'a=b, c=d'} | ${'darwin'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
${'a=b, c=d'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
`(
'checking addINIValues on $os_version',
async ({ini_values, os_version, output}) => {
expect(await config.addINIValues(ini_values, os_version)).toContain(
output
);
}
);
});

0 comments on commit 19a0187

Please sign in to comment.