Giter Club home page Giter Club logo

Comments (5)

egil avatar egil commented on June 12, 2024 3

That's a good point. Let's add that to the docs so folks find them when googling.

from bunit.

egil avatar egil commented on June 12, 2024

Pretty sure it's because your test class by default inherits from ComponentBase which you don't want when using it to write tests.

Change it to inherit from Test context instead, e.g. @inherits TestContext.

@inherits TestContext
@code {
[Fact]
public async Task Should_fire_ValueChanged_event_when_the_value_was_changed()
{
    var value = "foo";

    var webInput = Render<TestableWebInput<string>>(@<TestableWebInput
                                                                TValue="string"
                                                                @bind-Value="value">
                                                            </TestableWebInput>);

    var element = webInput.Find("input");

    var wasValueChangedFiredAfterFirstRender = value != "foo";

    await element.ChangeAsync(new() { Value = "bar" });

    Assert.Multiple(() => Assert.False(wasValueChangedFiredAfterFirstRender),
                    () => Assert.Equal("bar", webInput.Instance.Value));
}
}

from bunit.

iam3yal avatar iam3yal commented on June 12, 2024

@egil Thank you so much this was it! Keep up the amazing work you do. :)

p.s. I'm not sure whether this is documented but it might be worth adding a note about it.

from bunit.

linkdotnet avatar linkdotnet commented on June 12, 2024

@iam3yal https://bunit.dev/docs/providing-input/passing-parameters-to-components.html?tabs=razor#configure-two-way-with-component-parameters-bind-directive

from bunit.

iam3yal avatar iam3yal commented on June 12, 2024

@linkdotnet That's great but it's not SEO friendly simply because it doesn't note the exception so a person looking to resolve the problem might not find it but I guess that now that this issue exists it's sufficient. :)

from bunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.