I"’ (function() { describe("Quby.Collections.Flags", function() { describe("#initShowsHides", function() { beforeEach(function() { this.flagsC = new Quby.Collections.Flags; this.flag1 = new Quby.Models.Flag({ key: 'test1', hidesQuestionsKeys: ["v_1"], showsQuestionsKeys: ["v_2"] }); this.flag2 = new Quby.Models.Flag({ key: 'test2', hidesQuestionsKeys: ["v_2"], showsQuestionsKeys: ["v_1"] }); this.v_1 = new Quby.Models.Question({ key: "v_1" }); this.v_2 = new Quby.Models.Question({ key: "v_2" }); this.questions = new Quby.Collections.Questions([this.v_1, this.v_2]); return this.flagsC.add([this.flag1, this.flag2]); }); return it("calls initshowshides on each flag", function() { var spy1, spy2; spy1 = sinon.spy(this.flagsC.first(), 'initShowsHides'); spy2 = sinon.spy(this.flagsC.last(), 'initShowsHides'); this.flagsC.initShowsHides(this.questions); expect(spy1).toHaveBeenCalledWith(this.questions); return expect(spy2).toHaveBeenCalledWith(this.questions); }); }); return describe('#addFlags', function() { beforeEach(function() { return this.flagsC = new Quby.Collections.Flags; }); return it('combines the values from the flag_values object with the definitions from the flag_definitions object', function() { var flag_definitions, flag_values; flag_values = { smokes: true }; flag_definitions = { smokes: { key: "smokes", description_true: "De invuller rookt", description_false: "De invuller rookt niet", internal: false, shows_questions: ['v_33'], hides_questions: ['v_2'] }, last_measurement_of_day: { key: "last_measurement_of_day", description_true: "Laatste meting van de dag", description_false: "Niet de laatste meting van de dag", internal: true, shows_questions: [], hides_questions: [] } }; this.flagsC.addFlags(flag_definitions, flag_values); expect(this.flagsC.toArray()[0].get('key')).toEqual('smokes'); expect(this.flagsC.toArray()[0].get('value')).toEqual(true); expect(this.flagsC.toArray()[0].get('showsQuestionsKeys')).toEqual(['v_33']); expect(this.flagsC.toArray()[0].get('hidesQuestionsKeys')).toEqual(['v_2']); expect(this.flagsC.toArray()[1].get('key')).toEqual('last_measurement_of_day'); expect(this.flagsC.toArray()[1].get('value')).toEqual(null); expect(this.flagsC.toArray()[1].get('showsQuestionsKeys')).toEqual([]); return expect(this.flagsC.toArray()[1].get('hidesQuestionsKeys')).toEqual([]); }); }); }); }).call(this); :ET