Skip to content

Commit dbb851d

Browse files
anagstefimhoffd
authored andcommitted
fix(ion-button): Add a shape="round" attribute rule to ion-button (#101)
1 parent b9265d7 commit dbb851d

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/ionButtonAttributesRenamedRule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const replacementMap = new Map([
1717
['outline', 'fill="outline"'],
1818
['solid', 'fill="solid"'],
1919
['full', 'expand="full"'],
20-
['block', 'expand="block"']
20+
['block', 'expand="block"'],
21+
['round', 'shape="round"']
2122
]);
2223

2324
const IonButtonAttributesAreRenamedTemplateVisitor = createAttributesRenamedTemplateVisitorClass(['ion-button'], replacementMap);

test/ionButtonAttributesRenamed.spec.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,23 @@ describe(ruleName, () => {
203203
source
204204
});
205205
});
206+
207+
it('should fail when round is used', () => {
208+
let source = `
209+
@Component({
210+
template: \`
211+
<ion-button round></ion-button>\`
212+
~~~~~
213+
})
214+
class Bar{}
215+
`;
216+
217+
assertAnnotated({
218+
ruleName,
219+
message: 'The round attribute of ion-button has been renamed. Use shape="round" instead.',
220+
source
221+
});
222+
});
206223
});
207224

208225
describe('replacements', () => {
@@ -601,5 +618,41 @@ describe(ruleName, () => {
601618

602619
expect(res).to.eq(expected);
603620
});
621+
622+
it('should replace round with shape="round"', () => {
623+
let source = `
624+
@Component({
625+
template: \`<ion-button round></ion-button>
626+
\`
627+
})
628+
class Bar {}
629+
`;
630+
631+
const fail = {
632+
message: 'The round attribute of ion-button has been renamed. Use shape="round" instead.',
633+
startPosition: {
634+
line: 2,
635+
character: 33
636+
},
637+
endPosition: {
638+
line: 2,
639+
character: 38
640+
}
641+
};
642+
643+
const failures = assertFailure(ruleName, source, fail);
644+
const fixes = failures.map(f => f.getFix());
645+
const res = Replacement.applyAll(source, Utils.flatMap(fixes, Utils.arrayify));
646+
647+
let expected = `
648+
@Component({
649+
template: \`<ion-button shape="round"></ion-button>
650+
\`
651+
})
652+
class Bar {}
653+
`;
654+
655+
expect(res).to.eq(expected);
656+
});
604657
});
605658
});

0 commit comments

Comments
 (0)