From 15f9fcd3a626cb92b4e23d8195317f8a4263e721 Mon Sep 17 00:00:00 2001 From: Erik Lieben Date: Mon, 24 Oct 2016 11:00:57 +0200 Subject: [PATCH] feat(syntax): tokenize view-spy --- syntaxes/html.json | 13 ++++- test/syntax.html/view-spy.test.ts | 94 +++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 test/syntax.html/view-spy.test.ts diff --git a/syntaxes/html.json b/syntaxes/html.json index b8a101ff..2556e25e 100644 --- a/syntaxes/html.json +++ b/syntaxes/html.json @@ -187,6 +187,9 @@ { "include": "#tag-aurelia-compile-spy-attribute" }, + { + "include": "#tag-aurelia-view-spy-attribute" + }, { "include": "#tag-aurelia-replace-part-attribute" }, @@ -366,7 +369,15 @@ "name": "compile-spy.attribute.html.au" } } - }, + }, + "tag-aurelia-view-spy-attribute" : { + "match": "(view-spy)( |>)", + "captures": { + "1": { + "name": "view-spy.attribute.html.au" + } + } + }, "tag-aurelia-if-attribute" : { "match": "(?<=[^\"-])(if|naive-if)(?![-])(\\.)?(bind|one-way|two-way|one-time)?", "captures": { diff --git a/test/syntax.html/view-spy.test.ts b/test/syntax.html/view-spy.test.ts new file mode 100644 index 00000000..1a4ed27c --- /dev/null +++ b/test/syntax.html/view-spy.test.ts @@ -0,0 +1,94 @@ +import { assert } from 'chai'; +import { getTokenOnCharRange, hasScope, tokenizeLine } from './test.utils'; + +describe('The Aurelia HTML syntax view-spy attribute', () => { + + it('must tokenize view-spy attribute with scope "view-spy.attribute.html.au"', () => { + + // arrange + let scope = 'view-spy.attribute.html.au'; + + // act + let lineToken = tokenizeLine('

'); + + // assert + let token = getTokenOnCharRange(lineToken, 3, 11); + assert.isOk(hasScope(token.scopes, scope)); + + }); + + it('must not tokenize view-spy="" attribute', () => { + + // arrange + let scope = 'view-spy.attribute.html.au'; + + // act + let lineToken = tokenizeLine('

'); + + // assert + let token = getTokenOnCharRange(lineToken, 3, 11); + assert.isDefined(token); + assert.isNotOk(hasScope(token.scopes, scope)); + + }); + + it('must not tokenize view-spy-foo="" attribute', () => { + + // arrange + let scope = 'view-spy.attribute.html.au'; + + // act + let lineToken = tokenizeLine('

'); + + // assert + let token = getTokenOnCharRange(lineToken, 3, 15); + assert.isDefined(token); + assert.isNotOk(hasScope(token.scopes, scope)); + + }); + + it('must not tokenize foo-containerles="" attribute', () => { + + // arrange + let scope = 'view-spy.attribute.html.au'; + + // act + let lineToken = tokenizeLine('

'); + + // assert + let token = getTokenOnCharRange(lineToken, 3, 15); + assert.isDefined(token); + assert.isNotOk(hasScope(token.scopes, scope)); + + }); + + it('must not tokenize foo-view-spy="boo" attribute', () => { + + // arrange + let scope = 'view-spy.attribute.html.au'; + + // act + let lineToken = tokenizeLine('

'); + + // assert + let token = getTokenOnCharRange(lineToken, 3, 15); + assert.isDefined(token); + assert.isNotOk(hasScope(token.scopes, scope)); + + }); + + it('must not tokenize view-spyfoo="boo" attribute', () => { + + // arrange + let scope = 'view-spy.attribute.html.au'; + + // act + let lineToken = tokenizeLine('

'); + + // assert + let token = getTokenOnCharRange(lineToken, 3, 14); + assert.isDefined(token); + assert.isNotOk(hasScope(token.scopes, scope)); + + }); +});