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;
|
const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`]).version;
|
||||||
return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
|
return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
|
||||||
} catch {}
|
} catch {}
|
||||||
/* istanbul ignore next */
|
|
||||||
return '';
|
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();
|
const locatorHash = libvips.yarnLocator();
|
||||||
if (locatorHash.length) {
|
assert.strictEqual(locatorHash, '86cc8ee6e4');
|
||||||
assert.strict(locatorHash.length, 10);
|
delete process.env.npm_config_platform;
|
||||||
assert.strict(/[a-f0-9]{10}/.test(locatorHash));
|
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