Add specs for more image path cases
This commit is contained in:
parent
9c88a5c1ab
commit
97930fcd84
1 changed files with 24 additions and 3 deletions
|
@ -6,9 +6,30 @@ const path = require('path');
|
|||
|
||||
describe('nativeImage module', () => {
|
||||
describe('createFromPath(path)', () => {
|
||||
it('normalizes the path', () => {
|
||||
const nonAbsolutePath = `${path.join(__dirname, 'fixtures', 'api')}${path.sep}..${path.sep}${path.join('assets', 'logo.png')}`;
|
||||
const image = nativeImage.createFromPath(nonAbsolutePath);
|
||||
it('returns an empty image for invalid paths', () => {
|
||||
assert(nativeImage.createFromPath('').isEmpty());
|
||||
assert(nativeImage.createFromPath('does-not-exist.png').isEmpty());
|
||||
});
|
||||
|
||||
it('loads images from paths relative to the current working directory', () => {
|
||||
const imagePath = `.${path.sep}${path.join('spec', 'fixtures', 'assets', 'logo.png')}`;
|
||||
const image = nativeImage.createFromPath(imagePath);
|
||||
assert(!image.isEmpty());
|
||||
assert.equal(image.getSize().height, 190);
|
||||
assert.equal(image.getSize().width, 538);
|
||||
})
|
||||
|
||||
it('loads images from paths with `.` segments', () => {
|
||||
const imagePath = `${path.join(__dirname, 'fixtures')}${path.sep}.${path.sep}${path.join('assets', 'logo.png')}`;
|
||||
const image = nativeImage.createFromPath(imagePath);
|
||||
assert(!image.isEmpty());
|
||||
assert.equal(image.getSize().height, 190);
|
||||
assert.equal(image.getSize().width, 538);
|
||||
});
|
||||
|
||||
it('loads images from path with `..` segments', () => {
|
||||
const imagePath = `${path.join(__dirname, 'fixtures', 'api')}${path.sep}..${path.sep}${path.join('assets', 'logo.png')}`;
|
||||
const image = nativeImage.createFromPath(imagePath);
|
||||
assert(!image.isEmpty());
|
||||
assert.equal(image.getSize().height, 190);
|
||||
assert.equal(image.getSize().width, 538);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue