Generalise and fix the tests
This commit is contained in:
parent
dc8078f8d6
commit
1713d2bef4
1 changed files with 29 additions and 27 deletions
|
@ -1,5 +1,5 @@
|
||||||
import {
|
import {
|
||||||
readManifest, collect, toContentTypes, ReadmeProcessor,
|
readManifest, collect, toContentTypes, MarkdownProcessor,
|
||||||
read, processFiles, createDefaultProcessors,
|
read, processFiles, createDefaultProcessors,
|
||||||
toVsixManifest, IFile, validateManifest
|
toVsixManifest, IFile, validateManifest
|
||||||
} from '../package';
|
} from '../package';
|
||||||
|
@ -195,7 +195,8 @@ describe('toVsixManifest', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should treat README.md as asset', () => {
|
['readme', 'changelog'].forEach((fileType) => {
|
||||||
|
it(`should treat ${fileType.toUpperCase()}.md as asset`, () => {
|
||||||
const manifest = {
|
const manifest = {
|
||||||
name: 'test',
|
name: 'test',
|
||||||
publisher: 'mocha',
|
publisher: 'mocha',
|
||||||
|
@ -205,7 +206,7 @@ describe('toVsixManifest', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const files = [
|
const files = [
|
||||||
{ path: 'extension/readme.md', contents: new Buffer('') }
|
{ path: `extension/${fileType}.md`, contents: new Buffer('') }
|
||||||
];
|
];
|
||||||
|
|
||||||
return _toVsixManifest(manifest, files)
|
return _toVsixManifest(manifest, files)
|
||||||
|
@ -213,9 +214,10 @@ describe('toVsixManifest', () => {
|
||||||
.then(result => {
|
.then(result => {
|
||||||
assert.equal(result.PackageManifest.Assets[0].Asset.length, 2);
|
assert.equal(result.PackageManifest.Assets[0].Asset.length, 2);
|
||||||
assert.equal(result.PackageManifest.Assets[0].Asset[1].$.Type, 'Microsoft.VisualStudio.Services.Content.Details');
|
assert.equal(result.PackageManifest.Assets[0].Asset[1].$.Type, 'Microsoft.VisualStudio.Services.Content.Details');
|
||||||
assert.equal(result.PackageManifest.Assets[0].Asset[1].$.Path, 'extension/readme.md');
|
assert.equal(result.PackageManifest.Assets[0].Asset[1].$.Path, `extension/${fileType}.md`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
|
||||||
it('should respect display name', () => {
|
it('should respect display name', () => {
|
||||||
const manifest = {
|
const manifest = {
|
||||||
|
@ -1001,7 +1003,7 @@ describe('toContentTypes', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ReadmeProcessor', () => {
|
describe('MarkdownProcessor', () => {
|
||||||
|
|
||||||
it('should be no-op when no baseContentUrl is provided', () => {
|
it('should be no-op when no baseContentUrl is provided', () => {
|
||||||
const manifest = {
|
const manifest = {
|
||||||
|
@ -1013,7 +1015,7 @@ describe('ReadmeProcessor', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const root = fixture('readme');
|
const root = fixture('readme');
|
||||||
const processor = new ReadmeProcessor(manifest);
|
const processor = new MarkdownProcessor(manifest, {}, /^extension\/readme.md$/i);
|
||||||
const readme = {
|
const readme = {
|
||||||
path: 'extension/readme.md',
|
path: 'extension/readme.md',
|
||||||
localPath: path.join(root, 'readme.md')
|
localPath: path.join(root, 'readme.md')
|
||||||
|
@ -1039,10 +1041,10 @@ describe('ReadmeProcessor', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const root = fixture('readme');
|
const root = fixture('readme');
|
||||||
const processor = new ReadmeProcessor(manifest, {
|
const processor = new MarkdownProcessor(manifest, {
|
||||||
baseContentUrl: 'https://github.com/username/repository/blob/master',
|
baseContentUrl: 'https://github.com/username/repository/blob/master',
|
||||||
baseImagesUrl: 'https://github.com/username/repository/raw/master'
|
baseImagesUrl: 'https://github.com/username/repository/raw/master'
|
||||||
});
|
}, /^extension\/readme.md$/i);
|
||||||
const readme = {
|
const readme = {
|
||||||
path: 'extension/readme.md',
|
path: 'extension/readme.md',
|
||||||
localPath: path.join(root, 'readme.md')
|
localPath: path.join(root, 'readme.md')
|
||||||
|
@ -1069,7 +1071,7 @@ describe('ReadmeProcessor', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const root = fixture('readme');
|
const root = fixture('readme');
|
||||||
const processor = new ReadmeProcessor(manifest);
|
const processor = new MarkdownProcessor(manifest, {}, /^extension\/readme.md$/i);
|
||||||
const readme = {
|
const readme = {
|
||||||
path: 'extension/readme.md',
|
path: 'extension/readme.md',
|
||||||
localPath: path.join(root, 'readme.md')
|
localPath: path.join(root, 'readme.md')
|
||||||
|
@ -1096,7 +1098,7 @@ describe('ReadmeProcessor', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const root = fixture('readme');
|
const root = fixture('readme');
|
||||||
const processor = new ReadmeProcessor(manifest);
|
const processor = new MarkdownProcessor(manifest, {}, /^extension\/readme.md$/i);
|
||||||
const readme = {
|
const readme = {
|
||||||
path: 'extension/readme.md',
|
path: 'extension/readme.md',
|
||||||
localPath: path.join(root, 'readme.md')
|
localPath: path.join(root, 'readme.md')
|
||||||
|
@ -1127,7 +1129,7 @@ describe('ReadmeProcessor', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const root = fixture('readme');
|
const root = fixture('readme');
|
||||||
const processor = new ReadmeProcessor(manifest, options);
|
const processor = new MarkdownProcessor(manifest, options, /^extension\/readme.md$/i);
|
||||||
const readme = {
|
const readme = {
|
||||||
path: 'extension/readme.md',
|
path: 'extension/readme.md',
|
||||||
localPath: path.join(root, 'readme.md')
|
localPath: path.join(root, 'readme.md')
|
||||||
|
|
Loading…
Add table
Reference in a new issue