mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Tests: improve yarn locator coverage
This commit is contained in:
parent
6e02f9288e
commit
95ba045a69
@ -106,7 +106,6 @@ const yarnLocator = () => {
|
||||
const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`]).version;
|
||||
return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
|
||||
} catch {}
|
||||
/* istanbul ignore next */
|
||||
return '';
|
||||
};
|
||||
|
||||
|
@ -145,11 +145,22 @@ describe('libvips binaries', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('yarn locator hash', () => {
|
||||
describe('yarn locator hash', () => {
|
||||
it('known platform', () => {
|
||||
process.env.npm_config_platform = 'linux';
|
||||
process.env.npm_config_arch = 's390x';
|
||||
const locatorHash = libvips.yarnLocator();
|
||||
if (locatorHash.length) {
|
||||
assert.strict(locatorHash.length, 10);
|
||||
assert.strict(/[a-f0-9]{10}/.test(locatorHash));
|
||||
}
|
||||
assert.strictEqual(locatorHash, '86cc8ee6e4');
|
||||
delete process.env.npm_config_platform;
|
||||
delete process.env.npm_config_arch;
|
||||
});
|
||||
it('unknown platform', () => {
|
||||
process.env.npm_config_platform = 'unknown-platform';
|
||||
process.env.npm_config_arch = 'unknown-arch';
|
||||
const locatorHash = libvips.yarnLocator();
|
||||
assert.strictEqual(locatorHash, '');
|
||||
delete process.env.npm_config_platform;
|
||||
delete process.env.npm_config_arch;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user