Skip to content

Commit

Permalink
fix(ion-button): Add a shape="round" attribute rule to ion-button (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
anagstef authored and imhoffd committed Apr 7, 2019
1 parent b9265d7 commit dbb851d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ionButtonAttributesRenamedRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const replacementMap = new Map([
['outline', 'fill="outline"'],
['solid', 'fill="solid"'],
['full', 'expand="full"'],
['block', 'expand="block"']
['block', 'expand="block"'],
['round', 'shape="round"']
]);

const IonButtonAttributesAreRenamedTemplateVisitor = createAttributesRenamedTemplateVisitorClass(['ion-button'], replacementMap);
Expand Down
53 changes: 53 additions & 0 deletions test/ionButtonAttributesRenamed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,23 @@ describe(ruleName, () => {
source
});
});

it('should fail when round is used', () => {
let source = `
@Component({
template: \`
<ion-button round></ion-button>\`
~~~~~
})
class Bar{}
`;

assertAnnotated({
ruleName,
message: 'The round attribute of ion-button has been renamed. Use shape="round" instead.',
source
});
});
});

describe('replacements', () => {
Expand Down Expand Up @@ -601,5 +618,41 @@ describe(ruleName, () => {

expect(res).to.eq(expected);
});

it('should replace round with shape="round"', () => {
let source = `
@Component({
template: \`<ion-button round></ion-button>
\`
})
class Bar {}
`;

const fail = {
message: 'The round attribute of ion-button has been renamed. Use shape="round" instead.',
startPosition: {
line: 2,
character: 33
},
endPosition: {
line: 2,
character: 38
}
};

const failures = assertFailure(ruleName, source, fail);
const fixes = failures.map(f => f.getFix());
const res = Replacement.applyAll(source, Utils.flatMap(fixes, Utils.arrayify));

let expected = `
@Component({
template: \`<ion-button shape="round"></ion-button>
\`
})
class Bar {}
`;

expect(res).to.eq(expected);
});
});
});

0 comments on commit dbb851d

Please sign in to comment.