Skip to content

Commit

Permalink
add PR 5476 test
Browse files Browse the repository at this point in the history
tmp
  • Loading branch information
Wumu authored and IBG committed May 7, 2024
1 parent f11675a commit 1787561
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 3 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"eslint": "eslint lib test",
"pretest": "npm run clean && npm run build",
"test": "mocha test/scripts/**/*.ts --require ts-node/register",
"yapinTest": "mocha --file test/scripts/hexo/post.ts --grep \"yapinxxx test\" --require ts-node/register --timeout 10000",
"test-cov": "c8 --reporter=lcovonly npm test -- --no-parallel",
"prepare": "husky install"
},
Expand Down Expand Up @@ -66,7 +67,6 @@
"warehouse": "^5.0.1"
},
"devDependencies": {
"0x": "^5.1.2",
"@types/abbrev": "^1.1.3",
"@types/bluebird": "^3.5.37",
"@types/chai": "^4.3.11",
Expand All @@ -77,16 +77,17 @@
"@types/rewire": "^2.5.30",
"@types/sinon": "^17.0.3",
"@types/text-table": "^0.2.4",
"0x": "^5.1.2",
"c8": "^9.0.0",
"chai": "^4.3.6",
"cheerio": "0.22.0",
"decache": "^4.6.1",
"eslint": "^8.48.0",
"eslint-config-hexo": "^5.0.0",
"hexo-renderer-marked": "^6.0.0",
"husky": "^8.0.1",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"mocha": "^10.0.0",
"mocha": "^10.4.0",
"rewire": "^7.0.0",
"sinon": "^17.0.1",
"ts-node": "^10.9.1",
Expand Down
80 changes: 80 additions & 0 deletions test/scripts/hexo/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,86 @@ describe('Post', () => {
await unlink(data.path);
});

// #5476 - yapinxxx
// it('publish() - filenames separated by spaces', async () => {
it('yapinxxx test', async () => {

const assetDir = join(hexo.source_dir, '_drafts');
const assetSpaceDir = join(assetDir, 'space file');
const assetSpace1Dir = join(assetDir, 'space file test1');
const assetSpace2Dir = join(assetDir, 'space file test2');
const assetSpace3Dir = join(assetDir, 'space file test 3');
const assetSpace4Dir = join(assetDir, 'space file test 4');


console.log(assetSpace1Dir, '####space 1 dir');
console.log(assetSpace3Dir, '####space 3 dir');
console.log(assetSpace4Dir, '####space 4 dir');

const newAssetDir = join(hexo.source_dir, '_posts');
const date = moment(now);
hexo.config.post_asset_folder = true;

const write_content = 'This is Hello World with Space';
const template = [
'---',
'title: Hello World',
'date: ' + date.format('YYYY-MM-DD HH:mm:ss'),
'tags:',
'---'
].join('\n') + '\n';

const content = [template, write_content].join('\n');

// Put some files into the asset folder
await Promise.all([
writeFile(join(assetDir, 'space file.txt'), write_content),
writeFile(join(assetDir, 'space file test 0.txt'), write_content),
writeFile(join(assetDir, 'space file test 1.txt'), write_content),
writeFile(join(assetDir, 'space file test2.txt'), write_content),
writeFile(join(assetDir, 'space file test 3.txt'), write_content),

writeFile(join(assetSpaceDir, 'space file.txt'), write_content),

writeFile(join(assetSpace1Dir, 'space file10.txt'), write_content),
writeFile(join(assetSpace1Dir, 'space file test11.txt'), write_content),
writeFile(join(assetSpace1Dir, 'space file test12.txt'), write_content),
writeFile(join(assetSpace1Dir, 'space file test 13.txt'), write_content),


writeFile(join(assetSpace2Dir, 'space file20.txt'), write_content),

writeFile(join(assetSpace3Dir, 'space file30.txt'), write_content),
writeFile(join(assetSpace3Dir, 'space file test31.txt'), write_content),
writeFile(join(assetSpace3Dir, 'space file test32.txt'), write_content),
writeFile(join(assetSpace3Dir, 'space file test 33.txt'), write_content),

writeFile(join(assetSpace4Dir, 'space file.txt'), write_content),
writeFile(join(assetSpace4Dir, 'space file test41.txt'), write_content),
writeFile(join(assetSpace4Dir, 'space file test42.txt'), write_content),
writeFile(join(assetSpace4Dir, 'space file test 43.txt'), write_content)
]);

const result = await post.publish({
slug: 'space file test',
title: 'Hello World'
});

listDir(assetDir).then(list => {
console.log(list, 'show all files asset ####');
});

listDir(newAssetDir).then(list => {
console.log(list, 'show all files new asset ####');
});

// result.path.should.eql(join(newAssetDir, 'space-file-test.md'));
// result.content.should.eql(content);

await unlink(result.path);
});


it('render()', async () => {
// TODO: validate data
const beforeHook = spy();
Expand Down

0 comments on commit 1787561

Please sign in to comment.