Skip to content

Commit

Permalink
feat(syntax): tokenize replace-part with replace-part.attribute.html.au
Browse files Browse the repository at this point in the history
  • Loading branch information
erik-lieben committed Oct 9, 2016
1 parent 52e4447 commit ffab125
Show file tree
Hide file tree
Showing 2 changed files with 200 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 @@ -181,6 +181,9 @@
{
"include": "#tag-aurelia-containerless-attribute"
},
{
"include": "#tag-aurelia-replace-part-attribute"
},
{
"include": "#tag-aurelia-bindable-attribute"
},
Expand Down Expand Up @@ -384,9 +387,17 @@
"name": "ref.attribute.html.au"
},
"tag-aurelia-attribute": {
"match": "[^=-]\\b(as-element|replace-part)",
"match": "[^=-]\\b(as-element)",
"name": "attribute.html.au"
},
"tag-aurelia-replace-part-attribute": {
"match": "(?<![\"'-])\\b(replace-part)(?=\\=)\\b",
"captures": {
"1": {
"name": "replace-part.attribute.html.au"
}
}
},
"tag-aurelia-replaceable-attribute": {
"match": "(?<!\"')\\b[^=-](replaceable)(?!-)\\b",
"captures": {
Expand Down
188 changes: 188 additions & 0 deletions test/syntax.html/replace-part.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import { assert } from 'chai';
import { getTokenOnCharRange, hasScope, tokenizeLine, writeOut } from './test.utils';

describe('The Aurelia HTML syntax replace-part attribute', () => {

it(`must tokenize (replace-part)="item-template" attribute with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replace-part.attribute.html.au';

// act
let lineToken = tokenizeLine('<template replace-part="item-template">');

// assert
let token = getTokenOnCharRange(lineToken, 10, 22);
assert.isOk(hasScope(token.scopes, scope));

});

it(`must tokenize (replace-part)='item-template' attribute with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replace-part.attribute.html.au';

// act
let lineToken = tokenizeLine('<template replace-part=\'item-template\'>');

// assert
let token = getTokenOnCharRange(lineToken, 10, 22);
assert.isOk(hasScope(token.scopes, scope));

});

it(`must not tokenize (replace-part) attribute with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replace-part.attribute.html.au';

// act
let lineToken = tokenizeLine('<template replace-part>');

// assert
let token = getTokenOnCharRange(lineToken, 10, 22);
assert.isOk(!hasScope(token.scopes, scope));

});

it(`must not tokenize class="replace-part" attribute body with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replaceable.attribute.html.au';

// act
let lineToken = tokenizeLine('<div class="replace-part">');

// assert
let token = getTokenOnCharRange(lineToken, 12, 24);
assert.isOk(!hasScope(token.scopes, scope));

});

it(`must not tokenize class='replace-part' attribute body with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replaceable.attribute.html.au';

// act
let lineToken = tokenizeLine('<div class=\'replace-part\'>');

// assert
let token = getTokenOnCharRange(lineToken, 12, 24);
assert.isOk(!hasScope(token.scopes, scope));

});

it(`must not tokenize (somereplace-part)="item-template" attribute body with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replaceable.attribute.html.au';

// act
let lineToken = tokenizeLine('<template somereplace-part="item-template">');

// assert
let token = getTokenOnCharRange(lineToken, 10, 26);
assert.isOk(!hasScope(token.scopes, scope));

});

it(`must not tokenize (somereplace-part)='item-template' attribute body with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replaceable.attribute.html.au';

// act
let lineToken = tokenizeLine('<template somereplace-part=\'item-template\'>');

// assert
let token = getTokenOnCharRange(lineToken, 10, 26);
assert.isOk(!hasScope(token.scopes, scope));

});

it(`must not tokenize (replace-partsome)="item-template" attribute body with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replaceable.attribute.html.au';

// act
let lineToken = tokenizeLine('<template replace-partsome="item-template">');

// assert
let token = getTokenOnCharRange(lineToken, 10, 26);
assert.isOk(!hasScope(token.scopes, scope));

});

it(`must not tokenize (replace-partsome)='item-template' attribute body with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replaceable.attribute.html.au';

// act
let lineToken = tokenizeLine('<template replace-partsome=\'item-template\'>');

// assert
let token = getTokenOnCharRange(lineToken, 10, 26);
assert.isOk(!hasScope(token.scopes, scope));

});

it(`must not tokenize (replace-part-some)="item-template" attribute body with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replaceable.attribute.html.au';

// act
let lineToken = tokenizeLine('<template replace-part-some="item-template">');

// assert
let token = getTokenOnCharRange(lineToken, 10, 27);
assert.isOk(!hasScope(token.scopes, scope));

});

it(`must not tokenize (replace-part-some)='item-template' attribute body with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replaceable.attribute.html.au';

// act
let lineToken = tokenizeLine('<template replace-part-some=\'item-template\'>');

// assert
let token = getTokenOnCharRange(lineToken, 10, 27);
assert.isOk(!hasScope(token.scopes, scope));

});

it(`must not tokenize (some-replace-part)="item-template" attribute body with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replaceable.attribute.html.au';

// act
let lineToken = tokenizeLine('<template some-replace-part="item-template">');

// assert
let token = getTokenOnCharRange(lineToken, 10, 27);
assert.isOk(!hasScope(token.scopes, scope));

});

it(`must not tokenize (some-replace-part)='item-template' attribute body with scope "replace-part.attribute.html.au"`, () => {

// arrange
let scope = 'replaceable.attribute.html.au';

// act
let lineToken = tokenizeLine('<template some-replace-part=\'item-template\'>');

// assert
let token = getTokenOnCharRange(lineToken, 10, 27);
assert.isOk(!hasScope(token.scopes, scope));

});

});

0 comments on commit ffab125

Please sign in to comment.