@@ -1256,4 +1256,76 @@ describe('post', () => {
12561256 unlink ( file . source )
12571257 ] ) ;
12581258 } ) ;
1259+
1260+ it ( 'asset - post - common render' , async ( ) => {
1261+ hexo . config . post_asset_folder = true ;
1262+
1263+ const file = newFile ( {
1264+ path : 'foo.md' ,
1265+ published : true ,
1266+ type : 'create' ,
1267+ renderable : true
1268+ } ) ;
1269+
1270+ const assetFile = newFile ( {
1271+ path : 'foo/test.yml' ,
1272+ published : true ,
1273+ type : 'create'
1274+ } ) ;
1275+
1276+ await Promise . all ( [
1277+ writeFile ( file . source , 'test' ) ,
1278+ writeFile ( assetFile . source , 'test' )
1279+ ] ) ;
1280+ await process ( file ) ;
1281+ const id = 'source/' + assetFile . path ;
1282+ const post = Post . findOne ( { source : file . path } ) ;
1283+ PostAsset . findById ( id ) . renderable . should . be . true ;
1284+
1285+ hexo . config . post_asset_folder = false ;
1286+
1287+ return Promise . all ( [
1288+ unlink ( file . source ) ,
1289+ unlink ( assetFile . source ) ,
1290+ post . remove ( ) ,
1291+ PostAsset . removeById ( id )
1292+ ] ) ;
1293+ } ) ;
1294+
1295+ it ( 'asset - post - skip render' , async ( ) => {
1296+ hexo . config . post_asset_folder = true ;
1297+ hexo . config . skip_render = '**.yml' ;
1298+
1299+ const file = newFile ( {
1300+ path : 'foo.md' ,
1301+ published : true ,
1302+ type : 'create' ,
1303+ renderable : true
1304+ } ) ;
1305+
1306+ const assetFile = newFile ( {
1307+ path : 'foo/test.yml' ,
1308+ published : true ,
1309+ type : 'create'
1310+ } ) ;
1311+
1312+ await Promise . all ( [
1313+ writeFile ( file . source , 'test' ) ,
1314+ writeFile ( assetFile . source , 'test' )
1315+ ] ) ;
1316+ await process ( file ) ;
1317+ const id = 'source/' + assetFile . path ;
1318+ const post = Post . findOne ( { source : file . path } ) ;
1319+ PostAsset . findById ( id ) . renderable . should . be . false ;
1320+
1321+ hexo . config . post_asset_folder = false ;
1322+ hexo . config . skip_render = '' ;
1323+
1324+ return Promise . all ( [
1325+ unlink ( file . source ) ,
1326+ unlink ( assetFile . source ) ,
1327+ post . remove ( ) ,
1328+ PostAsset . removeById ( id )
1329+ ] ) ;
1330+ } ) ;
12591331} ) ;
0 commit comments