def test_can_render_markup_for_all_scripts(self):
     foo_script = Script('/foo.js')
     bar_script = Script('/bar.js')
     scripts = Scripts()
     scripts.add(foo_script)
     scripts.add(bar_script)
     assert_equals(foo_script.render()+bar_script.render(), scripts.render())
Exemplo n.º 2
0
    def test_can_replace_script_with_key(self):
        foo_script = Script('/foo.js', key='foo')
        bar_script = Script('/bar.js', key='foo')

        scripts = Scripts()
        scripts.add(foo_script)
        scripts.replace_script_with_key(bar_script)
        assert_length(1, scripts)
        assert_contains(bar_script, scripts.scripts)
Exemplo n.º 3
0
 def test_can_render_markup_for_all_scripts(self):
     foo_script = Script('/foo.js')
     bar_script = Script('/bar.js')
     scripts = Scripts()
     scripts.add(foo_script)
     scripts.add(bar_script)
     assert_equals(foo_script.render()+bar_script.render(), scripts.render())
Exemplo n.º 4
0
 def test_does_not_add_duplicate_scripts(self):
     scripts = Scripts()
     scripts.add(Script('/foo.js'))
     scripts.add(Script('/foo.js'))
     assert_length(1, scripts)
Exemplo n.º 5
0
 def test_can_add_scripts_during_instantiation(self):
     scripts = Scripts(Script('/foo.js'), Script('/bar.js'))
     assert_length(2, scripts)
Exemplo n.º 6
0
 def test_can_add_a_script(self):
     scripts = Scripts()
     scripts.add(Script('/foo.js'))
     assert_length(1, scripts)
Exemplo n.º 7
0
 def test_can_tell_that_another_script_is_not_equal(self):
     first = Script('/foo.js')
     assert_not_equals(first, Script('/bar.js'))
     assert_not_equals(first, None)
Exemplo n.º 8
0
 def test_can_tell_if_another_script_is_equal(self):
     first = Script('/foo.js')
     second = Script('/foo.js')
     assert_equals(first, first)
     assert_equals(first, second)
     assert_equals(second, first)
Exemplo n.º 9
0
    # --- duplicate handling ---------------------------------------------------

    def test_does_not_add_duplicate_scripts(self):
        scripts = Scripts()
        scripts.add(Script('/foo.js'))
        scripts.add(Script('/foo.js'))
        assert_length(1, scripts)

    def test_uses_non_async_if_conflicting_variants_are_added(self):
        scripts = Scripts()
        scripts.add(Script('/foo.js', async=True))
        assert_length(1, scripts)
        assert_true(scripts.scripts[0]. async)

        scripts.add(Script('/foo.js'))
        assert_length(1, scripts)
        assert_false(scripts.scripts[0]. async)

    # --- replacing scripts ----------------------------------------------------

    def test_can_replace_script_with_key(self):
        foo_script = Script('/foo.js', key='foo')
        bar_script = Script('/bar.js', key='foo')

        scripts = Scripts()
        scripts.add(foo_script)
        scripts.replace_script_with_key(bar_script)
        assert_length(1, scripts)
        assert_contains(bar_script, scripts.scripts)
Exemplo n.º 10
0
 def test_can_multiple_scripts(self):
     scripts = Scripts()
     scripts.add_all(Script('/foo.js'), Script('/bar.js'))
     assert_length(2, scripts)