Last active
December 16, 2023 21:06
-
-
Save mike-north/abe0fcd1cde655f9bfd4a694764af625 to your computer and use it in GitHub Desktop.
EmberLearn - Ember.Object
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
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
import Resolver from '../../resolver'; | |
import config from '../../config/environment'; | |
const resolver = Resolver.create(); | |
resolver.namespace = { | |
modulePrefix: config.modulePrefix, | |
podModulePrefix: config.podModulePrefix | |
}; | |
export default resolver; |
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
import resolver from './helpers/resolver'; | |
import { | |
setResolver | |
} from 'ember-qunit'; | |
setResolver(resolver); |
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
import { module, test } from 'qunit'; | |
if (require.entries['twiddle/utils/course']) { | |
module('Ember.Object | Modeling Data'); | |
const Course = require('twiddle/utils/course').default; | |
// Replace this with your real tests. | |
test('Correct defaults for data', function(assert) { | |
let course = Course.create(); | |
assert.equal(course.get('title'), 'No Title', 'title defaults to "No Title"'); | |
assert.equal(course.get('description'), '', 'description defaults to empty string'); | |
assert.deepEqual(course.get('tags'), [], 'tags defaults to empty array'); | |
}); | |
test('Adding and removing tags', function(assert) { | |
let course = Course.create(); | |
let otherCourse = Course.create(); | |
course.get('tags').addObject('front end'); | |
assert.equal(otherCourse.get('tags').length, 0, 'Adding tags to a course does not result in it being added to all courses\ncourse1.get("tags").addObject("a");\nshould not additionally add the tag "a" to course2'); | |
}); | |
test('Getting a language from a language ID', function(assert) { | |
let course = Course.create(); | |
assert.ok(typeof course.languageName === 'undefined', 'There should NOT be a function "languageName" on the course instance.\nThe proper place for this function is on the course class (using Ember.Object#reopenClass)'); | |
assert.equal(Course.languageName('js'), 'JavaScript', 'Course.languageName("js") returns "JavaScript"'); | |
assert.equal(Course.languageName(null), 'Unknown', 'Course.languageName() returns "Unknown"'); | |
}); | |
} |
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
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": true | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
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
import Ember from 'ember'; | |
/** | |
* Requirements | |
* | |
* I want to be able to create an instance of | |
* this new type of object | |
* | |
* let myCourse = Course.create(); | |
* | |
* and then we should be able to get and set | |
* serveral properties (title, description, tags) | |
* on this instance | |
* | |
* myCourse.set('description', 'In this course, we'll learn about cats!') | |
* | |
* Additionally, you need to make a class method | |
* for taking abbreviated programming language | |
* names, and expanding them. | |
* | |
* Course.languageName('js') // returns "JavaScript" | |
* | |
* Keep in mind that this function needs to be on the | |
* class, not on instances of the class. | |
*/ | |
const Course = Ember.Object.extend({ | |
}); | |
export default Course; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment