ember.js - Unit test Ember models without application running -
what best way unit test ember model without application running in test framework?
i couldn't find information how this. got following work, think covers needs, there smarter way this? i'm stabbing @ dark bit attempt i'm guessing there is.
`import { test, modulefor } 'ember-qunit'` `import subject 'school/models/subject'` `import student 'school/models/student'` #use subclass remove relationships, add default values set functions work. subjecttester = subject.extend { students: null name: '' } studenttester = student.extend { subject: null name: '' height: 0 } modulefor('model:subject') #use _create skip store, manually set relationships test('computes tallest student description', -> elise = studenttester._create() elise.set('height', 165) elise.set('name', 'elise') jasmine = studenttester._create() jasmine.set('height', 170) jasmine.set('name', 'jasmine') subject = subjecttester._create() subject.set('name', 'maths') subject.set('students', [elise, jasmine]) equal(subject.get('talleststudentdesc'), 'jasmine tallest student in maths') )
i tried using reopen instead of subclassing couldn't clean changes properly...
would better set test containers , stores? should use integration tests? missing obvious? pointers appreciated.
Comments
Post a Comment