-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49fd740
commit fd95301
Showing
8 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
tagName: 'button', | ||
|
||
operator: null, | ||
|
||
click() { | ||
this.get('onClick')(this.get('operator')); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Ember from 'ember'; | ||
|
||
export function formatOperator(params/*, hash*/) { | ||
var formatted; | ||
switch (params[0]) { | ||
case "+": | ||
formatted = "+"; | ||
break; | ||
case "-": | ||
formatted = "-"; | ||
break; | ||
case "*": | ||
formatted = "×"; | ||
break; | ||
case "%": | ||
formatted = "÷"; | ||
break; | ||
} | ||
return new Ember.Handlebars.SafeString(formatted); | ||
} | ||
|
||
export default Ember.Helper.helper(formatOperator); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{format-operator operator}} |
25 changes: 25 additions & 0 deletions
25
tests/integration/components/change-operator-button-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
moduleForComponent('change-operator-button', 'Integration | Component | change operator button', { | ||
integration: true | ||
}); | ||
|
||
test('it renders', function(assert) { | ||
|
||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... });" + EOL + EOL + | ||
|
||
this.render(hbs`{{change-operator-button}}`); | ||
|
||
assert.equal(this.$().text().trim(), ''); | ||
|
||
// Template block usage:" + EOL + | ||
this.render(hbs` | ||
{{#change-operator-button}} | ||
template block text | ||
{{/change-operator-button}} | ||
`); | ||
|
||
assert.equal(this.$().text().trim(), 'template block text'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { formatOperator } from '../../../helpers/format-operator'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Unit | Helper | format operator'); | ||
|
||
// Replace this with your real tests. | ||
test('it works', function(assert) { | ||
let result = formatOperator(42); | ||
assert.ok(result); | ||
}); |