Add tests for about page
This commit is contained in:
parent
54ed5681fb
commit
8078e69430
2 changed files with 17 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
||||||
from tests import TestCase
|
from tests import TestCase
|
||||||
from config import social as social_settings
|
from config import social as social_settings
|
||||||
|
import pelicanconf as settings
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,18 +48,6 @@ class AboutPageTestCase(TestCase):
|
||||||
self.assertHeaderTitle(content, 'About')
|
self.assertHeaderTitle(content, 'About')
|
||||||
self.assertTitle(content, 'About')
|
self.assertTitle(content, 'About')
|
||||||
|
|
||||||
def test_website_section(self):
|
|
||||||
content = self.client.get('about/index.html')
|
|
||||||
section = content.find('section', id='website')
|
|
||||||
subtitle = section.find('h2')
|
|
||||||
self.assertEqual('Website', self.get_children(subtitle))
|
|
||||||
|
|
||||||
def test_server_section(self):
|
|
||||||
content = self.client.get('about/index.html')
|
|
||||||
section = content.find('section', id='server')
|
|
||||||
subtitle = section.find('h2')
|
|
||||||
self.assertEqual('Server', self.get_children(subtitle))
|
|
||||||
|
|
||||||
def test_github_card(self):
|
def test_github_card(self):
|
||||||
content = self.client.get('about/index.html')
|
content = self.client.get('about/index.html')
|
||||||
tags = content.find_all('div', class_='github-card')
|
tags = content.find_all('div', class_='github-card')
|
||||||
|
@ -67,6 +56,19 @@ class AboutPageTestCase(TestCase):
|
||||||
self.assertEqual('medium', tag.attrs['data-theme'])
|
self.assertEqual('medium', tag.attrs['data-theme'])
|
||||||
self.assertEqual(social_settings['accounts']['github'][1], tag.attrs['data-github'])
|
self.assertEqual(social_settings['accounts']['github'][1], tag.attrs['data-github'])
|
||||||
|
|
||||||
|
def test_accounts(self):
|
||||||
|
content = self.client.get('about/index.html')
|
||||||
|
accounts = content.find_all('div', class_='account')
|
||||||
|
defined_accounts = [s for k, s in settings.ACCOUNTS.items()]
|
||||||
|
self.assertEqual(len(accounts), len(defined_accounts))
|
||||||
|
site_names = [s['site'] for s in defined_accounts]
|
||||||
|
urls = [s['url'] for s in defined_accounts]
|
||||||
|
icons = [s['icon'] for s in defined_accounts]
|
||||||
|
for account in accounts:
|
||||||
|
self.assertIn(account.find('a').attrs['href'], urls)
|
||||||
|
self.assertIn(account.find('i').attrs['class'][-1], icons)
|
||||||
|
self.assertIn(self.get_children(account.find('h3')), site_names)
|
||||||
|
|
||||||
|
|
||||||
class Page404TestCase(TestCase):
|
class Page404TestCase(TestCase):
|
||||||
def test_title(self):
|
def test_title(self):
|
||||||
|
|
|
@ -31,21 +31,13 @@ $('.navbar-brand').bind('click', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.panel-heading').bind('click', function () {
|
|
||||||
var ele = $(this);
|
|
||||||
if (ele.find('.panel-body').hasClass('ascii-hidden')) {
|
|
||||||
ele = ele.find('.panel-body');
|
|
||||||
var raw_code = ele.text().split(' ');
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.protected-mailto').bind('click', function (evt) {
|
$('.protected-mailto').bind('click', function (evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
var char_codes = $(this).data('value').split(' ');
|
var char_codes = $(this).data('value').split(' ');
|
||||||
var plain_text = []
|
var plain_text = [];
|
||||||
for(var i=0; i<char_codes.length; i++) {
|
for (var i = 0; i < char_codes.length; i++) {
|
||||||
plain_text.push(String.fromCharCode(parseInt(char_codes[i])));
|
plain_text.push(String.fromCharCode(parseInt(char_codes[i], 10)));
|
||||||
}
|
}
|
||||||
window.location = 'mailto:' + plain_text.join('');
|
window.location = 'mailto:' + plain_text.join('');
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue