Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for background image #29

Merged
merged 2 commits into from
Mar 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion drag_and_drop_v2/public/js/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@
h('div.close.icon-remove-sign.fa-times-circle'),
h('p.popup-content', {innerHTML: ctx.popup_html})
]),
h('div.target-img', {style: {backgroundImage: 'url(' + ctx.target_img_src + ')'}},
h('div.target-img', {style: {backgroundImage: ctx.target_img_src ?
'url(' + ctx.target_img_src + ')' :
undefined}},
renderCollection(zoneTemplate, ctx.zones, ctx))
]),
h('div.clear')
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/data/test_html_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@
"feedback": {
"start": "Intro <i>Feed</i>",
"finish": "Final <b>Feed</b>"
}
},
"targetImg": "https://www.edx.org/sites/default/files/theme/edx-logo-header.png"
}
5 changes: 5 additions & 0 deletions tests/integration/test_custom_data_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ def test_items_rendering(self):
self.assertIn('<i>B</i>', self.get_element_html(items[1]))
self.assertIn('<input class="input" type="text">', self.get_element_html(items[1]))
self.assertIn('<span style="color:red">X</span>', self.get_element_html(items[2]))

def test_background_image(self):
bg_image = self.browser.execute_script('return jQuery(".target-img").css("background-image")')
custom_image_url = 'https://www.edx.org/sites/default/files/theme/edx-logo-header.png'
self.assertEqual(bg_image, 'url("{}")'.format(custom_image_url))
7 changes: 6 additions & 1 deletion tests/integration/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class TestDragAndDropRender(BaseIntegrationTest):
"""
PAGE_TITLE = 'Drag and Drop v2'
PAGE_ID = 'drag_and_drop_v2'

def setUp(self):
super(TestDragAndDropRender, self).setUp()

Expand Down Expand Up @@ -60,3 +60,8 @@ def test_feedback(self):
feedback_message = self._get_feedback_message()

self.assertEqual(feedback_message.text, "Intro Feed")

def test_background_image(self):
bg_image = self.browser.execute_script('return jQuery(".target-img").css("background-image")')
image_path = '/resource/drag-and-drop-v2/public/img/triangle.png'
self.assertEqual(bg_image, 'url("{0}{1}")'.format(self.live_server_url, image_path))