Skip to content

Commit 823e2c1

Browse files
Erik Schillingoliverbock
authored andcommitted
Added test for prototype extension
1 parent b4e3cb5 commit 823e2c1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Tests/Noesis.Javascript.Tests/InstanceOfTest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,13 @@ public void UnregisteredObjectInstanceOfTest()
5454
_context.Invoking(x => x.Run("test instanceof Test"))
5555
.ShouldThrow<JavascriptException>().WithMessage("ReferenceError: Test is not defined");
5656
}
57+
58+
[TestMethod]
59+
public void ExtensionMethodIsPossible()
60+
{
61+
_context.SetConstructor("Test", typeof(TestClass), new Func<TestClass>(() => new TestClass()));
62+
_context.Run("Test.prototype.fooDuplicated = function() { return this.foo * 2; }");
63+
_context.Run("let x = new Test(); x.foo = 4; x.fooDuplicated() == 8").Should().Be(true);
64+
}
5765
}
5866
}

0 commit comments

Comments
 (0)