Skip to content

Commit

Permalink
add temporary type casting
Browse files Browse the repository at this point in the history
  • Loading branch information
idleberg committed May 25, 2024
1 parent 28ca61a commit d6a66cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions tests/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { test } from 'uvu';
import * as assert from 'uvu/assert';
import * as MakeNSIS from '../src/makensis';
import path from 'node:path';
import type Makensis from '../types';

const scriptFile = {
minimal: path.join(process.cwd(), 'tests', 'fixtures', 'utf8.nsi'),
Expand Down Expand Up @@ -77,17 +78,17 @@ test('Print compiler information', async () => {
});

test('Print compiler information as JSON', async () => {
const actual = (await MakeNSIS.headerInfo({ json: true })).stdout?.defined_symbols.__GLOBAL__;
const actual = ((await MakeNSIS.headerInfo({ json: true })).stdout as Makensis.HeaderInfo).defined_symbols.__GLOBAL__;
const expected = true;

assert.is(actual, expected);
});

test('Print help for all commands', async () => {
const output = await MakeNSIS.commandHelp();
const { stdout } = await MakeNSIS.commandHelp() as { stdout: string };

const expected = shared.commandHelp?.replace(/\s+/g, '');
const actual = output.stdout.replace(/\s+/g, '');
const actual = stdout.replace(/\s+/g, '');

assert.is(actual, expected);
});
Expand Down Expand Up @@ -245,7 +246,7 @@ test('Strict compilation with warning', async () => {

test('Print ${NSISDIR}', async () => {
try {
const nsisDir = await MakeNSIS.nsisDir();
const nsisDir = await MakeNSIS.nsisDir() as string;
const nsisCfg = path.join(nsisDir, 'Include', 'MUI2.nsh');

const expected = true;
Expand All @@ -259,8 +260,8 @@ test('Print ${NSISDIR}', async () => {

test('Print ${NSISDIR} as JSON', async () => {
try {
const nsisDir = await MakeNSIS.nsisDir({ json: true });
const nsisCfg = path.join(nsisDir.nsisdir, 'Include', 'MUI2.nsh');
const { nsisdir } = await MakeNSIS.nsisDir({ json: true }) as unknown as { nsisdir: string};
const nsisCfg = path.join(nsisdir, 'Include', 'MUI2.nsh');

const expected = true;
const actual = existsSync(nsisCfg);
Expand Down
2 changes: 1 addition & 1 deletion tests/encoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test('Compile script with incorrect charset', async () => {
const options = { ...defaultOptions, inputCharset: 'UTF16BE' };

try {
const { status } = MakeNSIS.compile(script['utf8'], options);
const { status } = await MakeNSIS.compile(script['utf8'], options) as { status: number };

const expected = 0;
const actual = status;
Expand Down
4 changes: 2 additions & 2 deletions tests/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test('Load magic environment variable from process', async () => {
const { stdout } = await MakeNSIS.compile(scriptFile, {
...defaultOptions,
env: true,
});
}) as { stdout: string };

const expected = true;
const actual = stdout.includes('NSIS_APP_MAGIC_ENVIRONMENT_VARIABLE') && stdout.includes(randomString);
Expand All @@ -58,7 +58,7 @@ test('Ignore magic environment variable', async () => {
const { stdout } = await MakeNSIS.compile(scriptFile, {
...defaultOptions,
env: false,
});
}) as { stdout: string };

const expected = true;
const actual = !stdout.includes(randomString);
Expand Down

0 comments on commit d6a66cb

Please sign in to comment.