Skip to content

Commit

Permalink
fix: Fix translation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Nov 19, 2024
1 parent 84696b5 commit 2e09028
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/commands/translate/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function testConfig<Config = TranslateConfig>(defaultArgs: string) {
config: DeepPartial<Config>,
result: Error | string,
): void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function _testConfig(name: string, args: string, config: any, result?: any): void {
it(name, async () => {
if (!result) {
Expand All @@ -59,9 +60,8 @@ export function testConfig<Config = TranslateConfig>(defaultArgs: string) {
});

if (result instanceof Error || typeof result === 'string') {
const message = result.message || result;
await expect(async () => runTranslate(defaultArgs + ' ' + args)).rejects.toThrow(
message,
result,
);
} else {
const instance = await runTranslate(defaultArgs + ' ' + args);
Expand Down
12 changes: 9 additions & 3 deletions src/commands/translate/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('Translate command', () => {
);

test(
'should handle args with priority',
'should handle args with priority',
'--source ru',
{
// @ts-ignore
Expand Down Expand Up @@ -312,8 +312,14 @@ describe('Translate command', () => {
});

it('should call provider translate with config', async () => {
const instance = await run('-o output --folder 1');
const instance = await run('-o output --folder 1 --source ru --target en --auth y0_1');

expect(instance.provider?.translate).toBeCalledWith(expect.objectContaining({}));
expect(instance.provider?.translate).toBeCalledWith(
expect.anything(),
expect.objectContaining({
input: expect.stringMatching(/^(\/|[A-Z]:\\).*?/),
output: expect.stringMatching(/^(\/|[A-Z]:\\).*?/),
}),
);
});
});
1 change: 1 addition & 0 deletions src/commands/translate/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export function resolveFiles(
result = glob.sync(extmatch, {
cwd: input,
nodir: true,
ignore: ['node_modules/**', '*/node_modules/**'],
});

if (exclude.length) {
Expand Down

0 comments on commit 2e09028

Please sign in to comment.