Open mathiasbynens opened 8 years ago
This would make it easier to test server/web/test/*.
server/web/test/*
pages:
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', 'mathias@qiwi.be', 'https://mathiasbynens.be/', 2910, NULL, '2010-07-24 13:40:49', '2012-07-03 17:38:16');
tests:
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?
create_pages.sql
create_tests.sql
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
npm run generate-test
This would make it easier to test
server/web/test/*
.pages
:tests
:Can this be added to
create_pages.sql
andcreate_tests.sql
respectively or is there a better way?