Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix transfer-test in window platform #927

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions src/fileHandlers/transfer/__tests__/transfer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ import localFs from '../../../core/localFs';
import TransferTask from '../../../core/transferTask';
import RemoteFs from '../../../../test/helper/localRemoteFs';

declare global {
interface Array<T> {
formatSep(): Array<T>;
}
}

Array.prototype.formatSep = function() {
return this.map(str => str.replace(/\//g, path.sep))
}

function createRemoteFs({ remoteTimeOffsetInHours = 0 } = {}) {
return new RemoteFs(path, {
clientOption: {} as any,
Expand Down Expand Up @@ -120,13 +130,13 @@ describe('transfer algorithm', () => {
expect(deleted.length).toEqual(0);
expect(mapList(task, 'targetFsPath').sort()).toEqual(
[
'/remote/a',
'/remote/b',
'/remote/c/c-a',
'/remote/c/c-b',
'/remote/c/d/d-a',
'/remote/c/d/d-b',
].sort()
`/remote/a`,
`/remote/b`,
`/remote/c/c-a`,
`/remote/c/c-b`,
`/remote/c/d/d-a`,
`/remote/c/d/d-b`,
].formatSep().sort()
);
});

Expand Down Expand Up @@ -177,7 +187,7 @@ describe('transfer algorithm', () => {
expect(task.length).toEqual(6);
expect(deleted.length).toEqual(3);
expect(mapList(deleted, 'fspath').sort()).toEqual(
['/remote/$da', '/remote/$db', '/remote/c/$dc'].sort()
['/remote/$da', '/remote/$db', '/remote/c/$dc'].formatSep().sort()
);
expect(mapList(task, 'targetFsPath').sort()).toEqual(
[
Expand All @@ -187,7 +197,7 @@ describe('transfer algorithm', () => {
'/remote/c/c-b',
'/remote/c/d/d-a',
'/remote/c/d/d-b',
].sort()
].formatSep().sort()
);
});

Expand Down Expand Up @@ -238,7 +248,7 @@ describe('transfer algorithm', () => {
expect(task.length).toEqual(6);
expect(deleted.length).toEqual(3);
expect(mapList(deleted, 'fspath').sort()).toEqual(
['/remote/$da', '/remote/$db', '/remote/c/$dc'].sort()
['/remote/$da', '/remote/$db', '/remote/c/$dc'].formatSep().sort()
);
expect(mapList(task, 'targetFsPath').sort()).toEqual(
[
Expand All @@ -248,7 +258,7 @@ describe('transfer algorithm', () => {
'/remote/c/c-b',
'/remote/c/d/d-a',
'/remote/c/d/d-b',
].sort()
].formatSep().sort()
);
});

Expand Down Expand Up @@ -287,7 +297,7 @@ describe('transfer algorithm', () => {
expect(task.length).toEqual(1);
expect(deleted.length).toEqual(0);
expect(mapList(task, 'targetFsPath').sort()).toEqual(
['/remote/a'].sort()
['/remote/a'].formatSep().sort()
);
task.length = 0;
deleted.length = 0;
Expand Down Expand Up @@ -340,7 +350,7 @@ describe('transfer algorithm', () => {
expect(task.length).toEqual(3);
expect(deleted.length).toEqual(0);
expect(mapList(task, 'targetFsPath').sort()).toEqual(
['/remote/a', '/remote/c/c-a', '/remote/c/d/d-a'].sort()
['/remote/a', '/remote/c/c-a', '/remote/c/d/d-a'].formatSep().sort()
);
});

Expand Down Expand Up @@ -393,7 +403,7 @@ describe('transfer algorithm', () => {
'/remote/c/c-b',
'/remote/c/d/d-a',
'/remote/c/d/d-b',
].sort()
].formatSep().sort()
);
});

Expand Down Expand Up @@ -455,7 +465,7 @@ describe('transfer algorithm', () => {
'/remote/c/d/d-a',
'/local/c/d/d-b',
'/local/c/d/d-c',
].sort()
].formatSep().sort()
);
});

Expand Down Expand Up @@ -516,7 +526,7 @@ describe('transfer algorithm', () => {
'/local/c/c-b',
'/remote/c/d/d-a',
'/local/c/d/d-b',
].sort()
].formatSep().sort()
);
});
});
Expand Down