ember.js - Testing Ember Data - Switching to FixtureAdapter during test runs -
I have and I am setting this as a Now I have a cube test and in that test I would like to swap the default restart for a fixture adapter so that I can set up the fixtures for my model. I think I have to write, but I'm not 100% sure: The above tests are end-to-end for the following amber view If you want to see this whole app in action (just a sample amber app with some basic jasmine tests) it is on the github DS.Store :
(function (app) {'strict use'; ... var store = DS.Store.extend ({revision: 12}); app.store = store;}) (Window.Balanced);
('strict use'; var fixtureAdapter; module ('tests.store.module', {Setup: function} {fixtureAdapter = DS.FixtureAdapter.extend ({}) Integrated.store.RePan ({adapter: fixtureAdapter}); // TODO: How does it work? Balanced Market .Fixtures = [ Id: 1, name: '1'}, {id: 2, name: 'poop'}, {id: 3, name: 'poop'}];}, teardown: function () {// teardown code}} ); Test ("market query", function () {var marketplace = balanced. Marketplace.find (); // TODO: how do I check it?});}) (); For my basic unit testing with Jasmine, I manually set up the shop manually (using)
Description (" CodeCamp.SessionView Test ", function () {var get = Ember.get, set = Ember Set, sut, controller, session, store; first each (function () {store = DS.Store.create ({revision: 11, adapter: DS.lasapter.create (}}) sut = CodeCamp.SessionView.create ( ); Control C = CodeCamp.SessionController.create (): controller.set ("store", store); sut.set ("controller", controller); session = codecamp.Session .createrecord ({id: 1, name: "first" , Room: "A", rating: [], speaker: [], tag: []};}); after each (function () {amber.ron (function) {store.destroy (); controller. (); Sut.destroy); Session.destroy ();}); store = null; controller = zero; sut = null; session = null;}); (When the "form is valid", function () {sut.set ('score', '1234'); sut.set ('response', 'a bcd'); sut.addRating; (session) var rating = codecamp (Rating '); Var rating (rating); Var Rating = Rating.Byget (0); Expected (rating.get (' score ')) toEqual (' 1234 '). Response ')) toEqual (' ABCD '). Expect (rating.get (' session ')) (' ID ').) ToEqual (1).)); });
CodeCamp.SessionView = Ember.View.extend ({templateName: 'Session', addRating: function (event) {if (this.formIsValid ()) {var rating = this.buildRatingFromInputs (event); this.get ('controller'). AddRating (rating); this.resetForm (); }} BuilderForminInput: Function (session) {var score = this.get ('score'); var response = this.get ('feedback'); return codecamp.arting.createrer (Score: Score, Feedback: Feedback, Session: Session});}, formIsValid: function () {var score = This.get ('score'); var response = this.get ('response'); if (score === undefined || response === undefined; Score.trim () === "". Feedback.trim () === "") {return returned;} return true;}, reset form: function () {this.set ('score', ''); This.set ('response', '');}} );
Comments
Post a Comment