jsperf.com
jsperf.com copied to clipboard
Add SQL for example tests
This would make it easier to test server/web/test/*
.
pages
:
INSERT INTO `pages` (`id`, `slug`, `revision`, `browserscopeID`, `title`, `info`, `setup`, `teardown`, `initHTML`, `visible`, `author`, `authorEmail`, `authorURL`, `hits`, `ip`, `published`, `updated`)
VALUES
(15, 'slugs', 1, 'agt1YS1wcm9maWxlcnINCxIEVGVzdBiH_6sRDA', 'Generating slugs', 'To generate a slug, do this:\r\n\r\n* Convert the string to lowercase\r\n* Replace every non-alphanumeric character with a hyphen (`-`)\r\n* Merge consecutive hyphens into one\r\n\r\nNote that following these steps still won’t turn `\"ïñtërnâtiônàlizætiøn\"` into `\"internationalization\"`. This was not a requirement in this case.', '', '', '<script>\r\n // custom colors\r\n ui.browserscope.colors = [\'pink\', \'#43C6DB\'];\r\n\r\n var arr = [\r\n \'This is just a test\', // → \"this-is-just-a-test\"\r\n \'Some “weird” characters: ©™® Awesome\', // → \"some-weird-characters-awesome\"\r\n \'Lorem ipsum 123 dolor\' // → \"lorem-ipsum-123-dolor\"\r\n ];\r\n\r\n\r\n</script>', 'y', 'Mathias Bynens', '[email protected]', 'https://mathiasbynens.be/', 2910, NULL, '2010-07-24 13:40:49', '2012-07-03 17:38:16');
tests
:
INSERT INTO `tests` (`testID`, `pageID`, `title`, `code`, `defer`)
VALUES
(62, 15, 'Using several `.replace()`s', 'var i = arr.length;\r\nwhile (i--) {\r\n arr[i].toLowerCase().replace(/[^a-z0-9-]+/g, \'-\').replace(/[-]+/g, \'-\').replace(/^-|-$/g, \'\');\r\n}', 'n'),
(63, 15, 'Using `.match()` and `.join()`', 'var i = arr.length;\r\nwhile (i--) {\r\n arr[i].toLowerCase().match(/[a-z0-9]+/ig).join(\'-\');\r\n}', 'n');
Can this be added to create_pages.sql
and create_tests.sql
respectively or is there a better way?
I think it would be nice to have a factory of sorts to create new tests. Suppose we could start by creating the same content over and over. Something like npm run generate-test
that would execute this SQL