Skip to content

Commit

Permalink
feat(syntax): tokenize view-spy
Browse files Browse the repository at this point in the history
  • Loading branch information
erik-lieben committed Oct 24, 2016
1 parent b9fa63e commit 15f9fcd
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 1 deletion.
13 changes: 12 additions & 1 deletion syntaxes/html.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
{
"include": "#tag-aurelia-compile-spy-attribute"
},
{
"include": "#tag-aurelia-view-spy-attribute"
},
{
"include": "#tag-aurelia-replace-part-attribute"
},
Expand Down Expand Up @@ -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": {
Expand Down
94 changes: 94 additions & 0 deletions test/syntax.html/view-spy.test.ts
Original file line number Diff line number Diff line change
@@ -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('<p view-spy foo="boo">');

// 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('<p view-spy="">');

// 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('<p view-spy-foo="">');

// 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('<p foo-view-spy="">');

// 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('<p foo-view-spy="boo">');

// 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('<p view-spyfoo="boo">');

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

});
});

0 comments on commit 15f9fcd

Please sign in to comment.