Skip to content

Commit

Permalink
improve test types
Browse files Browse the repository at this point in the history
  • Loading branch information
idleberg committed May 23, 2024
1 parent 791cf2c commit 9a89da9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
9 changes: 4 additions & 5 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 @@ -38,7 +39,6 @@ test('Print makensis version as JSON', async () => {
expected = JSON.stringify({ version: expected });

let actual = stdout;
actual.version = `${actual.version}`;
actual = JSON.stringify(actual);

assert.is(actual, expected);
Expand All @@ -63,7 +63,6 @@ test('Print makensis license as JSON', async () => {
expected = JSON.stringify({ license: expected });

let actual = stdout;
actual.license = `${actual.license}`;
actual = JSON.stringify(actual);

assert.is(actual, expected);
Expand All @@ -79,7 +78,7 @@ 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?.defined_symbols.__GLOBAL__;
const expected = true;

assert.is(actual, expected);
Expand Down Expand Up @@ -198,7 +197,7 @@ test('Compilation with warning as JSON', async () => {
test('Compilation with raw arguments and warning', async () => {
try {
const { status } = await MakeNSIS.compile(scriptFile.warning, {
rawArguments: ['-WX'],
rawArguments: '-WX',
});

const expected = 1;
Expand Down Expand Up @@ -261,7 +260,7 @@ test('Print ${NSISDIR}', async () => {

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

const expected = true;
Expand Down
3 changes: 2 additions & 1 deletion tests/encoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ 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';

// Compiler arguments
const script = {
// cp850: join(__dirname, 'fixtures', 'cp850.nsi'),
utf8: path.join(process.cwd(), 'tests', 'fixtures', 'utf8.nsi'),
};

const defaultOptions = {
const defaultOptions: Makensis.CompilerOptions = {
strict: true,
define: {
NULL_DEVICE: nullDevice,
Expand Down
4 changes: 3 additions & 1 deletion tests/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import * as MakeNSIS from '../src/makensis';
import path from 'node:path';
import which from 'which';

import type Makensis from '../types';

const scriptFile = path.join(process.cwd(), 'tests', 'fixtures', 'env.nsi');

const defaultOptions = {
const defaultOptions: Makensis.CompilerOptions = {
define: {
NULL_DEVICE: nullDevice,
},
Expand Down

0 comments on commit 9a89da9

Please sign in to comment.