Last active
December 10, 2015 15:28
-
-
Save blumysden/4454245 to your computer and use it in GitHub Desktop.
Shows how the approach we took yesterday fails...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Tiff problem v2', function() { | |
it('goes a little something like this', function() { | |
var NS = {}; | |
var Bing = function(myFoo) { | |
this.foo = myFoo; | |
}; | |
Bing.prototype = { | |
getFoo: function() { | |
return this.foo; | |
}, | |
updateFoo: function(prop, val) { | |
this.getFoo()[prop] = val; | |
}, | |
boom: function() { | |
return 1; | |
}, | |
identity: function() { | |
return this; | |
} | |
}; | |
NS.Foo = function() { | |
this.bar = 'bat'; | |
this.bing = new Bing(this); | |
}; | |
var foo = new NS.Foo(), | |
foo2 = new NS.Foo(); | |
expect(foo.bing.boom()).toEqual(1); | |
expect(foo.bing.identity()).toEqual(foo.bing); | |
expect(foo.bing.getFoo()).toEqual(foo); | |
foo.bing.updateFoo('bar', 'Tiff'); | |
expect(foo.bar).toBe('Tiff'); | |
}); | |
it('goes a little something like that', function() { | |
var NS = {}; | |
NS.Foo = function() { | |
this.bar = 'bat'; | |
this.bing.foo = this; | |
// this.bing = new Bing(this); | |
}; | |
NS.Foo.prototype = { | |
bing: { | |
// foo: null, | |
getFoo: function() { | |
return this.foo; | |
}, | |
updateFoo: function(prop, val) { | |
this.getFoo()[prop] = val; | |
}, | |
boom: function() { | |
return 1; | |
}, | |
identity: function() { | |
return this; | |
} | |
} | |
}; | |
var foo = new NS.Foo(); | |
foo2 = new NS.Foo(); | |
expect(foo.bing.boom()).toEqual(1); | |
expect(foo.bing.identity()).toEqual(foo.bing); | |
expect(foo.bing.getFoo()).toEqual(foo); | |
// THESE WILL FAIL!!! | |
expect(foo.bar).toBe('bat'); | |
foo.bing.updateFoo('bar', 'Tiff'); | |
expect(foo.bar).toBe('Tiff'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment