Skip to content

Instantly share code, notes, and snippets.

@robbiespeed
Last active December 11, 2020 19:55
Show Gist options
  • Save robbiespeed/6347b4c5006de13d33f73aa5cbca8d7d to your computer and use it in GitHub Desktop.
Save robbiespeed/6347b4c5006de13d33f73aa5cbca8d7d to your computer and use it in GitHub Desktop.
Ember Test
import Ember from 'ember';
const { get, set, computed } = Ember;
export default Ember.Controller.extend({
isButtonOn: false,
// This toggle will run when the button is pressed, it should toggle the isButtonOn property
// which should trigger the value of text to recompute
// -- begin edit area
toggle () {
},
text: computed(function () {
// -- end edit area
return get(this, 'isButtonOn') ?
'Congrats you\'ve fixed it and turned on the button' :
'You must fix controllers/application.js and press the button';
}),
});
<h1>Test</h1>
<button {{action toggle}}>
Button ({{if isButtonOn "On" "Off"}})
</button>
<br>
<br>
The text below should change when the button has been toggled
<br>
<br>
{{text}}
<br>
<br>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment