File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed
tests/integration/helpers Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 99 type Repository ,
1010 type NotFoundResponse ,
1111} from ' dealfront/controllers/application' ;
12+ import pluralize from ' dealfront/helpers/pluralize' ;
1213
1314interface BranchRowSignature {
1415 // The arguments accepted by the component
@@ -73,7 +74,10 @@ export default class BranchRow extends Component<BranchRowSignature> {
7374 >
7475 <td class =" df-cell" colspan =" 4" >
7576 {{#if this . branches.length }}
76- <h4 class =" branches-heading" >{{this .branches.length }} Branches</h4 >
77+ <h4 class =" branches-heading" >
78+ {{this .branches.length }}
79+ {{pluralize this . branches.length " branch" }}
80+ </h4 >
7781 {{/if }}
7882 <p class =" branches-paragraph" >
7983 {{#if this . getRepoBranches.isRunning }}
Original file line number Diff line number Diff line change 1+ import { helper } from '@ember/component/helper' ;
2+
3+ export default helper ( function pluralize ( [ number , word ] : [
4+ number ,
5+ string ,
6+ ] ) : string {
7+ const isSingle = number . toString ( ) . endsWith ( '1' ) ;
8+
9+ return isSingle ? word : word + 'es' ;
10+ } ) ;
Original file line number Diff line number Diff line change 1+ import { module , test } from ' qunit' ;
2+ import { setupRenderingTest } from ' dealfront/tests/helpers' ;
3+ import { render } from ' @ember/test-helpers' ;
4+ import pluralize from ' dealfront/helpers/pluralize' ;
5+
6+ module (' Integration | Helper | pluralize' , function (hooks ) {
7+ setupRenderingTest (hooks );
8+
9+ // TODO: Replace this with your real tests.
10+ test (' it renders' , async function (assert ) {
11+ const inputValue = [
12+ { number: 1 , word: ' branch' },
13+ { number: 12 , word: ' branches' },
14+ { number: 21 , word: ' branch' },
15+ ];
16+
17+ // await render(<template >{{pluralize inputValue [0 ] " branch" }} </template >);
18+
19+ for (const { number, word } of inputValue ) {
20+ await render (<template >{{pluralize number " branch" }} </template >);
21+ assert .dom ().hasText (word );
22+ }
23+ // assert.dom().hasText('12 branches');
24+ });
25+ });
You can’t perform that action at this time.
0 commit comments