@nkamennoff wrote:
I'm quite new to the ember community, and I have created a component that generates its content base on a given DS.Model object :
// templates/test.hbs {{my-component model=model.model modelName=model.modelName}} // routes/test.js import MyModel from 'app/models/my-model'; model() { model: MyModel, modelName: 'my-model' } // components/my-component.js modelAttributes: Ember.computed(function() { let model = this.get('model'); let attributes = []; // retrieves options if exists let labels = this.get('labels'); let requires = this.get('requires'); // Populating modelAttributes model.eachAttribute((attr, meta) => { let attributesInfo = {key: attr, type: meta.type, data: ''}; // do some stuff attributes.push(attributesInfo); }); return attributes; })
It works great but I'm quite stuck at testing this. Indeed I tried :
// tests/acceptances/components/my-component moduleForComponent('my-component', 'Integration | Component | my component', { integration: true }); const DummyModel = DS.Model.extend({ string: DS.attr('string'), email: DS.attr('email') }); test('it renders', function(assert) { this.set('modelDescription', DummyModel); this.set('modelName', 'dummy'); this.render(hbs`{{easy-crud modelName=modelName model=modelDescription}}`); // asserting stuff });
and using mirage to fake dummy objects. but it keeps on failing with the following error :
Died on test #1 at Module.callback (http://localhost:7357/assets/tests.js:698:24) at Module.exports (http://localhost:7357/assets/vendor.js:123:32) at requireModule (http://localhost:7357/assets/vendor.js:38:18) at TestLoader.require (http://localhost:7357/assets/test-support.js:6979:7) at TestLoader.loadModules (http://localhost:7357/assets/test-support.js:6971:14) at Function.TestLoader.load (http://localhost:7357/assets/test-support.js:7001:22) at http://localhost:7357/assets/test-support.js:6885:18: Unexpected token u in JSON at position 0
Does anyone have an idea ? Or am I doing something wrong ?
Thanks
Posts: 1
Participants: 1