Skip to content

Commit

Permalink
test: fix test error when commit git on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yunnysunny committed Jun 5, 2022
1 parent 713d8d4 commit 5b1ba9c
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions test/node/multipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getFullPath(filename) {
}

const fullPath = path.join(__dirname, '../../', filename);
return fullPath.charAt(0).toLowerCase() + fullPath.slice(1);
return fullPath;
}

describe('Multipart', () => {
Expand Down Expand Up @@ -104,7 +104,14 @@ describe('Multipart', () => {
assert.ok(Boolean(error), 'Request should have failed.');
error.code.should.equal('ENOENT');
error.message.should.containEql('ENOENT');
error.path.should.equal(getFullPath('foo'));
if (IS_WINDOWS) {
error.path.toLowerCase().should.equal(
getFullPath('foo').toLowerCase()
);
} else {
error.path.should.equal(getFullPath('foo'));
}

done();
});
});
Expand All @@ -118,7 +125,14 @@ describe('Multipart', () => {
(res) => assert.fail('It should not allow this'),
(err) => {
err.code.should.equal('ENOENT');
err.path.should.equal(getFullPath('does-not-exist.txt'));
if (IS_WINDOWS) {
err.path.toLowerCase().should.equal(
getFullPath('does-not-exist.txt').toLowerCase()
);
} else {
err.path.should.equal(getFullPath('does-not-exist.txt'));
}

}
);
});
Expand Down Expand Up @@ -190,9 +204,16 @@ describe('Multipart', () => {
.end((error, res) => {
assert.ok(Boolean(error), 'Request should have failed.');
error.code.should.equal('ENOENT');
error.path.should.equal(
getFullPath('test/node/fixtures/non-existent-file.ext')
);
if (IS_WINDOWS) {
error.path.toLowerCase().should.equal(
getFullPath('test/node/fixtures/non-existent-file.ext').toLowerCase()
);
} else {
error.path.should.equal(
getFullPath('test/node/fixtures/non-existent-file.ext')
);
}

done();
});
});
Expand Down

0 comments on commit 5b1ba9c

Please sign in to comment.