Skip to content

Commit 2a96c85

Browse files
committed
test: add unit test for asset id
1 parent 9ec56ac commit 2a96c85

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/scripts/processors/asset.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,28 @@ describe('asset', () => {
8383
return asset.remove();
8484
}).finally(() => fs.unlink(file.source));
8585
});
86+
it('asset - type: create (when source path is configed to parent directory)', () => {
87+
const file = newFile({
88+
path: '../../source/foo.jpg',
89+
type: 'create',
90+
renderable: false
91+
});
92+
93+
return fs.writeFile(file.source, 'foo').then(() => process(file)).then(() => {
94+
const id = '../source/foo.jpg'; // The id should a relative path,because the 'lib/models/assets.js' use asset path by joining base path with "_id" directly.
95+
const asset = Asset.findById(id);
96+
97+
asset._id.should.eql(id);
98+
asset.path.should.eql(file.path);
99+
asset.modified.should.be.true;
100+
asset.renderable.should.be.false;
86101

102+
return asset.remove();
103+
}).finally(() => {
104+
fs.unlink(file.source);
105+
fs.rmdir(pathFn.dirname(file.source));
106+
});
107+
});
87108
it('asset - type: update', () => {
88109
const file = newFile({
89110
path: 'foo.jpg',

0 commit comments

Comments
 (0)