|
@@ -20,12 +20,64 @@ require('utils/ember_computed');
|
|
|
|
|
|
describe('Ember.computed macros', function () {
|
|
|
|
|
|
+ beforeEach(function () {
|
|
|
+ App.reopen({
|
|
|
+ someRandomTestingKey: function () {
|
|
|
+ return this.get('someAnotherKey');
|
|
|
+ }.property('someAnotherKey'),
|
|
|
+ someAnotherKey: ''
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ afterEach(function () {
|
|
|
+ delete App.someAnotherKey;
|
|
|
+ delete App.someRandomTestingKey;
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('#equal', function () {
|
|
|
+
|
|
|
+ beforeEach(function () {
|
|
|
+ App.setProperties({
|
|
|
+ someAnotherKey: '123'
|
|
|
+ });
|
|
|
+ this.obj = Em.Object.create({
|
|
|
+ prop1: '123',
|
|
|
+ prop2: Em.computed.equal('prop1', '123'),
|
|
|
+ prop3: Em.computed.equal('App.someRandomTestingKey', '123')
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('`true` if values are equal', function () {
|
|
|
+ expect(this.obj.get('prop2')).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('`false` if values are not equal', function () {
|
|
|
+ this.obj.set('prop1', '321');
|
|
|
+ expect(this.obj.get('prop2')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('`prop3` depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop3')).to.be.true;
|
|
|
+ App.set('someAnotherKey', '');
|
|
|
+ expect(this.obj.get('prop3')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop3 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
describe('#notEqual', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.setProperties({
|
|
|
+ someAnotherKey: '123'
|
|
|
+ });
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: '123',
|
|
|
- prop2: Em.computed.notEqual('prop1', '123')
|
|
|
+ prop2: Em.computed.notEqual('prop1', '123'),
|
|
|
+ prop3: Em.computed.notEqual('App.someRandomTestingKey', '123')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -38,15 +90,28 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop2')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('`prop3` depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop3')).to.be.false;
|
|
|
+ App.set('someAnotherKey', '');
|
|
|
+ expect(this.obj.get('prop3')).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop3 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#equalProperties', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', '123');
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: '123',
|
|
|
prop2: '123',
|
|
|
- prop3: Em.computed.equalProperties('prop1', 'prop2')
|
|
|
+ prop3: Em.computed.equalProperties('prop1', 'prop2'),
|
|
|
+ prop4: Em.computed.equalProperties('App.someRandomTestingKey', 'prop2'),
|
|
|
+ prop5: Em.computed.equalProperties('prop1', 'App.someRandomTestingKey')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -59,15 +124,38 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop3')).to.be.false;
|
|
|
});
|
|
|
|
|
|
+ it('prop4 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop4')).to.be.true;
|
|
|
+ App.set('someAnotherKey', '');
|
|
|
+ expect(this.obj.get('prop4')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop5')).to.be.true;
|
|
|
+ App.set('someAnotherKey', '');
|
|
|
+ expect(this.obj.get('prop5')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop4 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#notEqualProperties', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', '123');
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: '123',
|
|
|
prop2: '123',
|
|
|
- prop3: Em.computed.notEqualProperties('prop1', 'prop2')
|
|
|
+ prop3: Em.computed.notEqualProperties('prop1', 'prop2'),
|
|
|
+ prop4: Em.computed.notEqualProperties('App.someRandomTestingKey', 'prop2'),
|
|
|
+ prop5: Em.computed.notEqualProperties('prop1', 'App.someRandomTestingKey')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -80,14 +168,36 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop3')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('prop4 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop4')).to.be.false;
|
|
|
+ App.set('someAnotherKey', '');
|
|
|
+ expect(this.obj.get('prop4')).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop5')).to.be.false;
|
|
|
+ App.set('someAnotherKey', '');
|
|
|
+ expect(this.obj.get('prop5')).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop4 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#ifThenElse', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', true);
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: true,
|
|
|
- prop2: Em.computed.ifThenElse('prop1', '1', '0')
|
|
|
+ prop2: Em.computed.ifThenElse('prop1', '1', '0'),
|
|
|
+ prop3: Em.computed.ifThenElse('App.someRandomTestingKey', '1', '0')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -100,17 +210,32 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop2')).to.equal('0');
|
|
|
});
|
|
|
|
|
|
+ it('prop3 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop3')).to.equal('1');
|
|
|
+ App.set('someAnotherKey', false);
|
|
|
+ expect(this.obj.get('prop3')).to.equal('0');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop3 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#and', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.setProperties({
|
|
|
+ someAnotherKey: true
|
|
|
+ });
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: true,
|
|
|
prop2: true,
|
|
|
prop3: true,
|
|
|
prop4: Em.computed.and('prop1', 'prop2', 'prop3'),
|
|
|
- prop5: Em.computed.and('prop1', '!prop2', '!prop3')
|
|
|
+ prop5: Em.computed.and('prop1', '!prop2', '!prop3'),
|
|
|
+ prop6: Em.computed.and('App.someRandomTestingKey', 'prop1'),
|
|
|
+ prop7: Em.computed.and('!App.someRandomTestingKey', 'prop1')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -142,17 +267,45 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop5')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('`prop6` depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop6')).to.be.true;
|
|
|
+ App.set('someAnotherKey', false);
|
|
|
+ expect(this.obj.get('prop6')).to.be.false;
|
|
|
+ App.set('someAnotherKey', true);
|
|
|
+ expect(this.obj.get('prop6')).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop6 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop6._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop1']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('`prop7` depends on inverted App.* key', function () {
|
|
|
+ expect(this.obj.get('prop7')).to.be.false;
|
|
|
+ App.set('someAnotherKey', false);
|
|
|
+ expect(this.obj.get('prop7')).to.be.true;
|
|
|
+ App.set('someAnotherKey', true);
|
|
|
+ expect(this.obj.get('prop7')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop7 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop7._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop1']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#or', function () {
|
|
|
-
|
|
|
beforeEach(function () {
|
|
|
+ App.setProperties({
|
|
|
+ someAnotherKey: true
|
|
|
+ });
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: false,
|
|
|
prop2: false,
|
|
|
prop3: false,
|
|
|
prop4: Em.computed.or('prop1', 'prop2', 'prop3'),
|
|
|
- prop5: Em.computed.or('!prop1', '!prop2', '!prop3')
|
|
|
+ prop5: Em.computed.or('!prop1', '!prop2', '!prop3'),
|
|
|
+ prop6: Em.computed.or('App.someRandomTestingKey', 'prop1'),
|
|
|
+ prop7: Em.computed.or('!App.someRandomTestingKey', 'prop1')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -185,16 +338,44 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop5')).to.be.false;
|
|
|
});
|
|
|
|
|
|
+ it('`prop6` depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop6')).to.be.true;
|
|
|
+ App.set('someAnotherKey', false);
|
|
|
+ expect(this.obj.get('prop6')).to.be.false;
|
|
|
+ App.set('someAnotherKey', true);
|
|
|
+ expect(this.obj.get('prop6')).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop6 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop6._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop1']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('`prop7` depends on inverted App.* key', function () {
|
|
|
+ expect(this.obj.get('prop7')).to.be.false;
|
|
|
+ App.set('someAnotherKey', false);
|
|
|
+ expect(this.obj.get('prop7')).to.be.true;
|
|
|
+ App.set('someAnotherKey', true);
|
|
|
+ expect(this.obj.get('prop7')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop7 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop7._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop1']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#sumProperties', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.setProperties({
|
|
|
+ someAnotherKey: 5
|
|
|
+ });
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 1,
|
|
|
prop2: 2,
|
|
|
prop3: 3,
|
|
|
- prop4: Em.computed.sumProperties('prop1', 'prop2', 'prop3')
|
|
|
+ prop4: Em.computed.sumProperties('prop1', 'prop2', 'prop3'),
|
|
|
+ prop5: Em.computed.sumProperties('prop1', 'prop2', 'App.someRandomTestingKey')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -222,14 +403,26 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop4')).to.equal(5);
|
|
|
});
|
|
|
|
|
|
+ it('`prop5` depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop5')).to.equal(8);
|
|
|
+ App.set('someAnotherKey', 6);
|
|
|
+ expect(this.obj.get('prop5')).to.equal(9);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'prop2', 'App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#gte', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', 4);
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 2,
|
|
|
- prop2: Em.computed.gte('prop1', 3)
|
|
|
+ prop2: Em.computed.gte('prop1', 3),
|
|
|
+ prop3: Em.computed.gte('App.someRandomTestingKey', 3)
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -247,15 +440,30 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop2')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('prop3 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop3')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 3);
|
|
|
+ expect(this.obj.get('prop3')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop3')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop3 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#gteProperties', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', 4);
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 2,
|
|
|
prop2: 3,
|
|
|
- prop3: Em.computed.gteProperties('prop1', 'prop2')
|
|
|
+ prop3: Em.computed.gteProperties('prop1', 'prop2'),
|
|
|
+ prop4: Em.computed.gteProperties('App.someRandomTestingKey', 'prop2'),
|
|
|
+ prop5: Em.computed.gteProperties('prop1', 'App.someRandomTestingKey')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -273,14 +481,40 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop3')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('prop4 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop4')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 3);
|
|
|
+ expect(this.obj.get('prop4')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop4')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop5')).to.be.false;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop5')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 1);
|
|
|
+ expect(this.obj.get('prop5')).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop4 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#lte', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', 0);
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 2,
|
|
|
- prop2: Em.computed.lte('prop1', 1)
|
|
|
+ prop2: Em.computed.lte('prop1', 1),
|
|
|
+ prop3: Em.computed.lte('App.someRandomTestingKey', 1)
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -298,15 +532,30 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop2')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('prop3 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop3')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 1);
|
|
|
+ expect(this.obj.get('prop3')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop3')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop3 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#lteProperties', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', 1);
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 2,
|
|
|
prop2: 1,
|
|
|
- prop3: Em.computed.lteProperties('prop1', 'prop2')
|
|
|
+ prop3: Em.computed.lteProperties('prop1', 'prop2'),
|
|
|
+ prop4: Em.computed.lteProperties('App.someRandomTestingKey', 'prop2'),
|
|
|
+ prop5: Em.computed.lteProperties('prop1', 'App.someRandomTestingKey')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -324,14 +573,40 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop3')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('prop4 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop4')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 0);
|
|
|
+ expect(this.obj.get('prop4')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop4')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop5')).to.be.false;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop5')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 3);
|
|
|
+ expect(this.obj.get('prop5')).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop4 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#gt', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', 4);
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 2,
|
|
|
- prop2: Em.computed.gt('prop1', 3)
|
|
|
+ prop2: Em.computed.gt('prop1', 3),
|
|
|
+ prop3: Em.computed.gt('App.someRandomTestingKey', 3)
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -349,15 +624,30 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop2')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('prop3 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop3')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 3);
|
|
|
+ expect(this.obj.get('prop3')).to.be.false;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop3')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop3 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#gtProperties', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', 4);
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 2,
|
|
|
prop2: 3,
|
|
|
- prop3: Em.computed.gtProperties('prop1', 'prop2')
|
|
|
+ prop3: Em.computed.gtProperties('prop1', 'prop2'),
|
|
|
+ prop4: Em.computed.gtProperties('App.someRandomTestingKey', 'prop2'),
|
|
|
+ prop5: Em.computed.gtProperties('prop1', 'App.someRandomTestingKey')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -375,14 +665,40 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop3')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('prop4 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop4')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 3);
|
|
|
+ expect(this.obj.get('prop4')).to.be.false;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop4')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop5')).to.be.false;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop5')).to.be.false;
|
|
|
+ App.set('someAnotherKey', 1);
|
|
|
+ expect(this.obj.get('prop5')).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop4 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#lt', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', 0);
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 2,
|
|
|
- prop2: Em.computed.lt('prop1', 1)
|
|
|
+ prop2: Em.computed.lt('prop1', 1),
|
|
|
+ prop3: Em.computed.lt('App.someRandomTestingKey', 1)
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -400,15 +716,30 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop2')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('prop3 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop3')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 1);
|
|
|
+ expect(this.obj.get('prop3')).to.be.false;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop3')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop3 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#ltProperties', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', 1);
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 2,
|
|
|
prop2: 1,
|
|
|
- prop3: Em.computed.ltProperties('prop1', 'prop2')
|
|
|
+ prop3: Em.computed.ltProperties('prop1', 'prop2'),
|
|
|
+ prop4: Em.computed.ltProperties('App.someRandomTestingKey', 'prop2'),
|
|
|
+ prop5: Em.computed.ltProperties('prop1', 'App.someRandomTestingKey')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -426,6 +757,30 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop3')).to.be.true;
|
|
|
});
|
|
|
|
|
|
+ it('prop4 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop4')).to.be.false;
|
|
|
+ App.set('someAnotherKey', 0);
|
|
|
+ expect(this.obj.get('prop4')).to.be.true;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop4')).to.be.false;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop5')).to.be.false;
|
|
|
+ App.set('someAnotherKey', 2);
|
|
|
+ expect(this.obj.get('prop5')).to.be.false;
|
|
|
+ App.set('someAnotherKey', 3);
|
|
|
+ expect(this.obj.get('prop5')).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop4 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#match', function () {
|
|
@@ -581,6 +936,7 @@ describe('Ember.computed macros', function () {
|
|
|
describe('#alias', function() {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.set('someAnotherKey', {a: {b: 1}});
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: {
|
|
|
a: {
|
|
@@ -589,7 +945,8 @@ describe('Ember.computed macros', function () {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- prop2: Em.computed.alias('prop1.a.b.c')
|
|
|
+ prop2: Em.computed.alias('prop1.a.b.c'),
|
|
|
+ prop3: Em.computed.alias('App.someAnotherKey.a.b')
|
|
|
})
|
|
|
});
|
|
|
|
|
@@ -602,6 +959,16 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop2')).to.equal(2);
|
|
|
});
|
|
|
|
|
|
+ it('prop3 depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop3')).to.equal(1);
|
|
|
+ App.set('someAnotherKey.a.b', 4);
|
|
|
+ expect(this.obj.get('prop3')).to.equal(4);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop3 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someAnotherKey.a.b']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#existsIn', function () {
|
|
@@ -632,14 +999,24 @@ describe('Ember.computed macros', function () {
|
|
|
describe('#percents', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+ App.setProperties({
|
|
|
+ p1: 25,
|
|
|
+ p2: 100
|
|
|
+ });
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 10,
|
|
|
prop2: 25,
|
|
|
prop3: Em.computed.percents('prop1', 'prop2'),
|
|
|
- prop4: Em.computed.percents('prop1', 'prop2', 2)
|
|
|
+ prop4: Em.computed.percents('prop1', 'prop2', 2),
|
|
|
+ prop5: Em.computed.percents('App.p1', 'App.p2', 1)
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ afterEach(function () {
|
|
|
+ delete App.p1;
|
|
|
+ delete App.p2;
|
|
|
+ });
|
|
|
+
|
|
|
it('should calculate percents', function () {
|
|
|
expect(this.obj.get('prop3')).to.equal(40);
|
|
|
expect(this.obj.get('prop4')).to.equal(40.00);
|
|
@@ -671,6 +1048,18 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop4')).to.equal(10.60);
|
|
|
});
|
|
|
|
|
|
+ it('prop5 depends on App.* keys', function () {
|
|
|
+ expect(this.obj.get('prop5')).to.equal(25.0);
|
|
|
+ App.set('p2', 50);
|
|
|
+ expect(this.obj.get('prop5')).to.equal(50.0);
|
|
|
+ App.set('p1', 10);
|
|
|
+ expect(this.obj.get('prop5')).to.equal(20.0);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop4 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['App.p1', 'App.p2']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#formatRole', function () {
|
|
@@ -730,11 +1119,21 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop2')).to.equal(10);
|
|
|
});
|
|
|
|
|
|
+ it('0 for empty collection', function () {
|
|
|
+ this.obj.set('prop1', []);
|
|
|
+ expect(this.obj.get('prop2')).to.equal(0);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#i18nFormat', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+
|
|
|
+ App.setProperties({
|
|
|
+ someAnotherKey: 'some value'
|
|
|
+ });
|
|
|
+
|
|
|
sinon.stub(Em.I18n, 't', function (key) {
|
|
|
var msgs = {
|
|
|
key1: '{0} {1} {2}'
|
|
@@ -746,7 +1145,8 @@ describe('Ember.computed macros', function () {
|
|
|
prop2: 'cba',
|
|
|
prop3: 'aaa',
|
|
|
prop4: Em.computed.i18nFormat('key1', 'prop1', 'prop2', 'prop3'),
|
|
|
- prop5: Em.computed.i18nFormat('not_existing_key', 'prop1', 'prop2', 'prop3')
|
|
|
+ prop5: Em.computed.i18nFormat('not_existing_key', 'prop1', 'prop2', 'prop3'),
|
|
|
+ prop6: Em.computed.i18nFormat('key1', 'App.someRandomTestingKey', 'prop2', 'prop3')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -771,16 +1171,33 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop5')).to.equal('');
|
|
|
});
|
|
|
|
|
|
+ it('`prop6` depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop6')).to.equal('some value cba aaa');
|
|
|
+ App.set('someAnotherKey', '');
|
|
|
+ expect(this.obj.get('prop6')).to.equal(' cba aaa');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop6 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop6._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2', 'prop3']);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#concat', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+
|
|
|
+ App.setProperties({
|
|
|
+ someAnotherKey: 'some value'
|
|
|
+ });
|
|
|
+
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: 'abc',
|
|
|
prop2: 'cba',
|
|
|
prop3: 'aaa',
|
|
|
- prop4: Em.computed.concat(' ', 'prop1', 'prop2', 'prop3')
|
|
|
+ prop4: Em.computed.concat(' ', 'prop1', 'prop2', 'prop3'),
|
|
|
+ prop5: Em.computed.concat(' ', 'App.someRandomTestingKey', 'prop2', 'prop3'),
|
|
|
+ prop6: Em.computed.concat(' ')
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -793,6 +1210,20 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop4')).to.equal('aaa cba aaa');
|
|
|
});
|
|
|
|
|
|
+ it('`prop5` depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop5')).to.equal('some value cba aaa');
|
|
|
+ App.set('someAnotherKey', '');
|
|
|
+ expect(this.obj.get('prop5')).to.equal(' cba aaa');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2', 'prop3']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop6 without dependent keys', function () {
|
|
|
+ expect(this.obj.get('prop6')).to.equal('');
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('#notExistsIn', function () {
|
|
@@ -823,11 +1254,18 @@ describe('Ember.computed macros', function () {
|
|
|
describe('#firstNotBlank', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
+
|
|
|
+ App.setProperties({
|
|
|
+ someAnotherKey: 'NOT-EMPTY-STRING'
|
|
|
+ });
|
|
|
+
|
|
|
this.obj = Em.Object.create({
|
|
|
prop1: '',
|
|
|
prop2: null,
|
|
|
prop3: '1234',
|
|
|
- prop4: Em.computed.firstNotBlank('prop1', 'prop2', 'prop3')
|
|
|
+ prop4: Em.computed.firstNotBlank('prop1', 'prop2', 'prop3'),
|
|
|
+ prop5: Em.computed.firstNotBlank('prop1', 'App.someRandomTestingKey', 'prop3'),
|
|
|
+ prop6: Em.computed.firstNotBlank('prop1', 'prop2')
|
|
|
})
|
|
|
});
|
|
|
|
|
@@ -850,6 +1288,22 @@ describe('Ember.computed macros', function () {
|
|
|
expect(this.obj.get('prop4')).to.equal('prop1 is used');
|
|
|
});
|
|
|
|
|
|
+ it('`prop5` depends on App.* key', function () {
|
|
|
+ expect(this.obj.get('prop5')).to.equal('NOT-EMPTY-STRING');
|
|
|
+ App.set('someAnotherKey', '!!!!!!!');
|
|
|
+ expect(this.obj.get('prop5')).to.equal('!!!!!!!');
|
|
|
+ App.set('someAnotherKey', null);
|
|
|
+ expect(this.obj.get('prop5')).to.equal('1234');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop5 dependent keys are valid', function () {
|
|
|
+ expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey', 'prop3']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('prop6 depends on blank values', function () {
|
|
|
+ expect(this.obj.get('prop6')).to.be.null;
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
});
|