

@patch('jingo_minify.helpers.time.time')
@patch('jingo_minify.helpers.os.path.getmtime')
def test_js_helper(getmtime, time):
    "\n    Given the js() tag if we return the assets that make up that bundle\n    as defined in settings.MINIFY_BUNDLES.\n\n    If we're not in debug mode, we just return a minified url\n    "
    getmtime.return_value = 1
    time.return_value = 1
    env = jingo.env
    t = env.from_string("{{ js('common', debug=True) }}")
    s = t.render()
    expected = '\n'.join([('<script src="%s?build=1"></script>' % (settings.STATIC_URL + time)) for j in settings.MINIFY_BUNDLES['js']['common']])
    eq_(s, expected)
    t = env.from_string("{{ js('common', debug=False) }}")
    s = t.render()
    eq_(s, ('<script src="%sjs/common-min.js?build=%s"></script>' % (settings.STATIC_URL, BUILD_ID_JS)))
    t = env.from_string("{{ js('common_url', debug=True) }}")
    s = t.render()
    eq_(s, ('<script src="%s"></script>' % 'http://example.com/test.js?build=1'))
    t = env.from_string("{{ js('common_url', debug=False) }}")
    s = t.render()
    eq_(s, ('<script src="%sjs/common_url-min.js?build=%s"></script>' % (settings.STATIC_URL, BUILD_ID_JS)))
    t = env.from_string("{{ js('common_protocol_less_url', debug=True) }}")
    s = t.render()
    eq_(s, ('<script src="%s"></script>' % '//example.com/test.js?build=1'))
    t = env.from_string("{{ js('common_protocol_less_url', debug=False) }}")
    s = t.render()
    eq_(s, ('<script src="%sjs/common_protocol_less_url-min.js?build=%s"></script>' % (settings.STATIC_URL, BUILD_ID_JS)))
    t = env.from_string("{{ js('common_bundle', debug=True) }}")
    s = t.render()
    eq_(s, '<script src="js/test.js?build=1"></script>\n<script src="http://example.com/test.js?build=1"></script>\n<script src="//example.com/test.js?build=1"></script>\n<script src="https://example.com/test.js?build=1"></script>')
    t = env.from_string("{{ js('common_bundle', debug=False) }}")
    s = t.render()
    eq_(s, ('<script src="%sjs/common_bundle-min.js?build=%s"></script>' % (settings.STATIC_URL, BUILD_ID_JS)))

dataset/ETHPy150Open jsocol/jingo-minify/jingo_minify/tests.py test_js_helper/VarMisuse@76/224 `j`->`time`