If I have the test like so, which should pass
expect("test".__proto__ === String.prototype).toBe(true)
it fails with the error Expected false to be true.
The reason I'm testing this is because in my code jquery extensions adds format to String.prototype. However, when I go todo my test
"my test {0}".format(1)
I get "undefined is not a function", and looking closer all string in a Jasmine test dont have the String.prototype as their prototype.
---EDIT--- After further testing I found that if I have:
it("test string prototype", function() {
var test_string = "test"
expect(test_string.__proto__ === String.prototype).toBe(true)
with (frameContext) {
expect(test_string.__proto__ === String.prototype).toBe(true)
}
});
the first expect passes but the second doesn't.
---EDIT---
expect(typeof String.prototype.format !== "undefined").toBe(true)
expect(test_string.__proto__ === String.prototype).toBe(true)
with (frameContext) {
expect(typeof String.prototype.format !== "undefined").toBe(true)
expect(test_string.__proto__ === String.prototype).toBe(true)
}
first expect fails, second expect passes
within the with, first expect pass, and second fails.