<reponame>marx-alex/napari-bleach-correct<filename>src/napari_bleach_correct/_tests/test_widget.py
from .._widgets import ratio_correct_widget, exponential_correct_widget, histogram_correct_widget
import numpy as np


def test_ratio_widget(make_napari_viewer, capsys):
    # make viewer and add an image layer using our fixture
    viewer = make_napari_viewer()
    viewer.add_image(np.random.random((5, 100, 100)))

    # create our widget, passing in the viewer
    my_widget = ratio_correct_widget(viewer)

    # call our widget method
    my_widget._on_click()

    # read captured output and check that it's as we expected
    captured = capsys.readouterr()
    assert captured.out == "napari has 1 layers\n"


def test_exponential_widget(make_napari_viewer, capsys):
    # make viewer and add an image layer using our fixture
    viewer = make_napari_viewer()
    viewer.add_image(np.random.random((5, 100, 100)))

    # create our widget, passing in the viewer
    my_widget = exponential_correct_widget(viewer)

    # call our widget method
    my_widget._on_click()

    # read captured output and check that it's as we expected
    captured = capsys.readouterr()
    assert captured.out == "napari has 1 layers\n"


def test_histogram_widget(make_napari_viewer, capsys):
    # make viewer and add an image layer using our fixture
    viewer = make_napari_viewer()
    viewer.add_image(np.random.random((5, 100, 100)))

    # create our widget, passing in the viewer
    my_widget = histogram_correct_widget(viewer)

    # call our widget method
    my_widget._on_click()

    # read captured output and check that it's as we expected
    captured = capsys.readouterr()
    assert captured.out == "napari has 1 layers\n"
