提交 4dcce12b 编写于 作者: G Guillaume Jenkins

Adding unit tests for Ionic HTML Intellisense

上级 ef63356c
......@@ -16,16 +16,16 @@ export interface IHTMLTagProvider {
collectValues(tag: string, attribute: string, collector: (value: string) => void): void;
}
export class HTMLTagSpecification {
constructor(public label: string, public attributes: string[] = []) { }
export interface ITagSet {
[tag: string]: HTMLTagSpecification;
}
interface ITagSet {
[tag: string]: HTMLTagSpecification
export class HTMLTagSpecification {
constructor(public label: string, public attributes: string[] = []) { }
}
interface IValueSets {
[tag: string]: string[]
[tag: string]: string[];
}
// HTML tag information sourced from http://www.w3.org/TR/2015/WD-html51-20151008/
......@@ -320,7 +320,7 @@ export const HTML_TAGS: ITagSet = {
export const IONIC_TAGS: ITagSet = {
'ion-checkbox': new HTMLTagSpecification('',
['name', 'ng-change', 'ng-false-value', 'ng-model', 'ng-true-value']),
['name', 'ng-false-value', 'ng-model', 'ng-true-value']),
'ion-content': new HTMLTagSpecification('',
['delegate-handle', 'direction:scrolldir', 'has-bouncing:b', 'locking:b', 'on-scroll', 'on-scroll-complete', 'overflow-scroll:b', 'padding:b', 'scroll:b', 'scrollbar-x:b', 'scrollbar-y:b', 'start-x', 'start-y']),
'ion-delete-button': new HTMLTagSpecification('',
......@@ -356,7 +356,7 @@ export const IONIC_TAGS: ITagSet = {
'ion-popover-view': new HTMLTagSpecification('',
[]),
'ion-radio': new HTMLTagSpecification('',
['disabled:b', 'icon', 'name', 'ng-change', 'ng-disabled:b', 'ng-model', 'ng-value', 'value']),
['disabled:b', 'icon', 'name', 'ng-disabled:b', 'ng-model', 'ng-value', 'value']),
'ion-refresher': new HTMLTagSpecification('',
['disable-pulling-rotation:b', 'on-pulling', 'on-refresh', 'pulling-icon', 'pulling-text', 'refreshing-icon', 'spinner']),
'ion-reorder-button': new HTMLTagSpecification('',
......@@ -382,7 +382,7 @@ export const IONIC_TAGS: ITagSet = {
'ion-title': new HTMLTagSpecification('',
[]),
'ion-toggle': new HTMLTagSpecification('',
['name', 'ng-change', 'ng-false-value', 'ng-model', 'ng-true-value', 'toggle-class']),
['name', 'ng-false-value', 'ng-model', 'ng-true-value', 'toggle-class']),
'ion-view ': new HTMLTagSpecification('',
['cache-view:b', 'can-swipe-back:b', 'hide-back-button:b', 'hide-nav-bar:b', 'view-title'])
};
......@@ -521,7 +521,8 @@ export function getIonicTagProvider(): IHTMLTagProvider {
var attributes = customTags[tag];
if (attributes) {
attributes.forEach((a) => {
collector(a, null);
var segments = a.split(':');
collector(segments[0], segments[1]);
});
}
}
......
......@@ -322,6 +322,67 @@ suite('HTML - worker', () => {
});
});
test('Intellisense Ionic', function(testDone): any {
WinJS.Promise.join([
// Try some Ionic tags
testSuggestionsFor('<|').then((completion) => {
assert.equal(completion.currentWord, '');
assertSuggestion(completion, 'ion-checkbox');
assertSuggestion(completion, 'ion-content');
assertSuggestion(completion, 'ion-nav-title');
}),
testSuggestionsFor('<ion-re|').then((completion) => {
assert.equal(completion.currentWord, 'ion-re');
assertSuggestion(completion, 'ion-refresher');
assertSuggestion(completion, 'ion-reorder-button');
}),
// Try some global attributes (1 with value suggestions, 1 without value suggestions, 1 void)
testSuggestionsFor('<ion-checkbox |').then((completion) => {
assert.equal(completion.currentWord, '');
assertSuggestion(completion, 'force-refresh-images');
assertSuggestion(completion, 'collection-repeat');
assertSuggestion(completion, 'menu-close');
}),
// Try some tag-specific attributes (1 with value suggestions, 1 void)
testSuggestionsFor('<ion-footer-bar |').then((completion) => {
assert.equal(completion.currentWord, '');
assertSuggestion(completion, 'align-title');
assertSuggestion(completion, 'keyboard-attach');
}),
// Try the extended attributes of an existing HTML 5 tag
testSuggestionsFor('<a |').then((completion) => {
assert.equal(completion.currentWord, '');
assertSuggestion(completion, 'nav-direction');
assertSuggestion(completion, 'nav-transition');
assertSuggestion(completion, 'href');
assertSuggestion(completion, 'hreflang');
}),
// Try value suggestion for a tag-specific attribute
testSuggestionsFor('<ion-side-menu side="|').then((completion) => {
assert.equal(completion.currentWord, '');
assertSuggestion(completion, 'left');
assertSuggestion(completion, 'primary');
assertSuggestion(completion, 'right');
assertSuggestion(completion, 'secondary');
}),
// Try a value suggestion for a global attribute
testSuggestionsFor('<img force-refresh-images="|').then((completion) => {
assert.equal(completion.currentWord, '');
assertSuggestion(completion, 'false');
assertSuggestion(completion, 'true');
}),
// Try a value suggestion for an extended attribute of an existing HTML 5 tag
testSuggestionsFor('<a nav-transition="|').then((completion) => {
assert.equal(completion.currentWord, '');
assertSuggestion(completion, 'android');
assertSuggestion(completion, 'ios');
assertSuggestion(completion, 'none');
})
]).done(() => testDone(), (errors:any[]) => {
testDone(errors.reduce((e1, e2) => e1 || e2));
});
});
function testLinkCreation(modelUrl:string, rootUrl:string, tokenContent:string, expected:string): void {
var _modelUrl = URI.parse(modelUrl);
var _rootUrl = rootUrl === null ? null : URI.parse(rootUrl);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册