提交 81f49529 编写于 作者: A Alex Dima

Markdown mode tests should not depend on Typescript mode

上级 7547666e
......@@ -4,24 +4,75 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/languages/markdown/common/markdown.contribution';
import 'vs/languages/typescript/common/typescript.contribution';
import 'vs/languages/html/common/html.contribution';
import 'vs/languages/css/common/css.contribution';
import modesUtil = require('vs/editor/test/common/modesUtil');
import Modes = require('vs/editor/common/modes');
import {htmlTokenTypes} from 'vs/languages/html/common/html';
import {cssTokenTypes} from 'vs/languages/css/common/css';
import {MockModeService} from 'vs/editor/test/common/mocks/mockModeService';
import {NULL_THREAD_SERVICE} from 'vs/platform/test/common/nullThreadService';
import {createInstantiationService} from 'vs/platform/instantiation/common/instantiationService';
import {MarkdownMode} from 'vs/languages/markdown/common/markdown';
import {MockTokenizingMode} from 'vs/editor/test/common/mocks/mockMode';
class MarkdownMockModeService extends MockModeService {
isRegisteredMode(mimetypeOrModeId: string): boolean {
if (mimetypeOrModeId === 'javascript') {
return true;
}
if (mimetypeOrModeId === 'css') {
return true;
}
throw new Error('Not implemented');
}
getMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): Modes.IMode {
if (commaSeparatedMimetypesOrCommaSeparatedIds === 'javascript') {
return new MockTokenizingMode('js', 'mock-js');
}
if (commaSeparatedMimetypesOrCommaSeparatedIds === 'css') {
return new MockTokenizingMode('css', 'mock-css');
}
throw new Error('Not implemented');
}
getModeIdForLanguageName(alias:string): string {
if (alias === 'text/javascript') {
return 'javascript';
}
if (alias === 'text/css') {
return 'css';
}
console.log(alias);
throw new Error('Not implemented');
}
}
suite('Markdown - tokenization', () => {
var tokenizationSupport: Modes.ITokenizationSupport;
setup((done) => {
modesUtil.load('markdown', ['html', 'javascript', 'css']).then(mode => {
tokenizationSupport = mode.tokenizationSupport;
done();
(function() {
let threadService = NULL_THREAD_SERVICE;
let modeService = new MarkdownMockModeService();
let inst = createInstantiationService({
threadService: threadService,
modeService: modeService
});
});
threadService.setInstantiationService(inst);
let mode = new MarkdownMode(
{ id: 'markdown' },
inst,
threadService,
modeService,
null,
null,
null
);
tokenizationSupport = mode.tokenizationSupport;
})();
test('', () => {
modesUtil.executeTests(tokenizationSupport, [
......@@ -46,10 +97,7 @@ suite('Markdown - tokenization', () => {
line: '<script>alert("foo")</script>*bar*',
tokens: [
{ startIndex:0, type: htmlTokenTypes.getTag('script.md') },
{ startIndex:8, type: 'identifier.js' },
{ startIndex:13, type: 'delimiter.parenthesis.js' },
{ startIndex:14, type: 'string.js' },
{ startIndex:19, type: 'delimiter.parenthesis.js' },
{ startIndex:8, type: 'mock-js' },
{ startIndex:20, type: htmlTokenTypes.getTag('script.md') },
{ startIndex:29, type: 'emphasis.md' }
]}],
......@@ -58,16 +106,7 @@ suite('Markdown - tokenization', () => {
line: '<style>div { background: red }</style>*bar*',
tokens: [
{ startIndex:0, type: htmlTokenTypes.getTag('style.md') },
{ startIndex:7, type: cssTokenTypes.TOKEN_SELECTOR_TAG + '.css' },
{ startIndex:10, type: '' },
{ startIndex:11, type: 'punctuation.bracket.css' },
{ startIndex:12, type: '' },
{ startIndex:13, type: cssTokenTypes.TOKEN_PROPERTY + '.css' },
{ startIndex:23, type: 'punctuation.css' },
{ startIndex:24, type: '' },
{ startIndex:25, type: cssTokenTypes.TOKEN_VALUE + '.css' },
{ startIndex:28, type: '' },
{ startIndex:29, type: 'punctuation.bracket.css' },
{ startIndex:7, type: 'mock-css' },
{ startIndex:30, type: htmlTokenTypes.getTag('style.md') },
{ startIndex:38, type: 'emphasis.md' }
]}]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册