Skip to content

Commit

Permalink
test: add unit test for asset id
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomingplus committed Mar 16, 2019
1 parent 9ec56ac commit 2a96c85
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/scripts/processors/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,28 @@ describe('asset', () => {
return asset.remove();
}).finally(() => fs.unlink(file.source));
});
it('asset - type: create (when source path is configed to parent directory)', () => {
const file = newFile({
path: '../../source/foo.jpg',
type: 'create',
renderable: false
});

return fs.writeFile(file.source, 'foo').then(() => process(file)).then(() => {
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.
const asset = Asset.findById(id);

asset._id.should.eql(id);
asset.path.should.eql(file.path);
asset.modified.should.be.true;
asset.renderable.should.be.false;

return asset.remove();
}).finally(() => {
fs.unlink(file.source);
fs.rmdir(pathFn.dirname(file.source));
});
});
it('asset - type: update', () => {
const file = newFile({
path: 'foo.jpg',
Expand Down

0 comments on commit 2a96c85

Please sign in to comment.