import pkg_resources


def mock_pkg_resources(monkeypatch):
    """Mock reading the build Javascript files."""
    def mock_read_file(*args, **kwargs):
        if args[1].endswith('.html'):
            return """<html>
            <head>
            </head>
            <body>
                <script>
                {bundle}
                </script>
                <div id="{id}">
                </div>
                <script>
                    opencleanVis.renderOpencleanVisBundle("#{id}", {data});
                </script>
            </body>
            </html>
            """.encode('utf-8')
        else:
            return 'function(){};'.encode('utf-8')

    monkeypatch.setattr(pkg_resources, "resource_string", mock_read_file)