コード例 #1
0
ファイル: watch_test.js プロジェクト: mjc/ngular
testBoth('watching an object value then unwatching should restore old value', function(get, set) {
  var obj = { foo: { bar: { baz: { biff: 'BIFF' } } } };
  addListeners(obj, 'foo.bar.baz.biff');

  watch(obj, 'foo.bar.baz.biff');

  var foo = Ngular.get(obj, 'foo');
  equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist');

  unwatch(obj, 'foo.bar.baz.biff');
  equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist');
});
コード例 #2
0
ファイル: watch_test.js プロジェクト: mjc/ngular
QUnit.test("watching an object THEN defining it should work also", function() {
  var obj = {};
  addListeners(obj, 'foo');

  watch(obj, 'foo');

  Ngular.defineProperty(obj, 'foo');
  Ngular.set(obj, 'foo', 'bar');

  equal(Ngular.get(obj, 'foo'), 'bar', 'should have set');
  equal(willCount, 1, 'should have invoked willChange once');
  equal(didCount, 1, 'should have invoked didChange once');

});