2018-06-25 05:00:12 +00:00
const { expectValidateFixturesResult } = require ( './lib' ) ;
2018-06-23 04:50:06 +00:00
2018-06-25 05:00:12 +00:00
describe ( 'validation success' , ( ) => {
it ( 'should succeed with valid data' , ( ) => {
expectValidateFixturesResult ( 'valid' , {
errorCount : 0 ,
output : [ ] ,
} ) ;
} ) ;
} ) ;
2018-06-23 04:50:06 +00:00
2018-06-25 05:00:12 +00:00
describe ( 'validation errors' , ( ) => {
2018-06-23 04:50:06 +00:00
it ( 'should catch invalid table rows' , ( ) => {
2018-06-25 05:00:12 +00:00
expectValidateFixturesResult ( 'bad-table-rows' , {
errorCount : 2 ,
2018-06-23 04:50:06 +00:00
output : [
2019-11-01 03:37:35 +00:00
'README.md: Expected 3 table cells but found 2: [10up](/company-profiles/10up.md) | https://10up.com/' ,
'README.md: Expected 3 table cells but found 4: [18F](/company-profiles/18f.md) | https://18f.gsa.gov/ | USA | something else' ,
2018-06-23 04:50:06 +00:00
] ,
} ) ;
} ) ;
it ( 'should catch missing company names' , ( ) => {
2018-06-25 05:00:12 +00:00
expectValidateFixturesResult ( 'missing-company-names' , {
errorCount : 11 ,
2018-06-23 04:50:06 +00:00
output : [
2019-10-14 18:14:56 +00:00
'README.md: Company "⚠⚠⚠" has no linked Markdown profile ("/company-profiles/.md")' ,
2018-06-23 04:50:06 +00:00
'README.md: Missing company name: <td></td><td><a href="https://andyet.com">https://andyet.com</a></td><td>Worldwide</td>' ,
'README.md: Company is listed out of order: "" (should be before "⚠⚠⚠")' ,
2019-10-14 18:14:56 +00:00
'README.md: Company "" has no linked Markdown profile ("/company-profiles/.md")' ,
2018-06-23 04:50:06 +00:00
'README.md: Missing company name: <td><a href="/company-profiles/10up.md"></a> ⚠</td><td><a href="https://10up.com/">https://10up.com/</a></td><td>Worldwide</td>' ,
'README.md: Missing company name: <td><a href="/company-profiles/17hats.md"></a></td><td><a href="https://www.17hats.com/">https://www.17hats.com/</a></td><td>Worldwide</td>' ,
'README.md: Missing company name: <td></td><td><a href="https://18f.gsa.gov/">https://18f.gsa.gov/</a></td><td>USA</td>' ,
2019-10-14 18:14:56 +00:00
'README.md: Company "" has no linked Markdown profile ("/company-profiles/.md")' ,
2018-06-25 02:42:33 +00:00
'10up.md: Profile looks complete, but the main readme contains a warning emoji.' ,
2018-06-23 04:50:06 +00:00
'18f.md: No link to company profile from readme' ,
'and-yet.md: No link to company profile from readme' ,
] ,
} ) ;
} ) ;
2020-05-06 06:42:21 +00:00
it ( 'should catch duplicate company names' , ( ) => {
expectValidateFixturesResult ( 'duplicate-company' , {
errorCount : 1 ,
output : [
'README.md: Duplicate company: &Yet' ,
]
} ) ;
} ) ;
2018-06-23 04:50:06 +00:00
it ( 'should catch unsorted company names' , ( ) => {
2018-06-25 05:00:12 +00:00
expectValidateFixturesResult ( 'unsorted' , {
errorCount : 2 ,
2018-06-23 04:50:06 +00:00
output : [
'README.md: Company is listed out of order: "17hats" (should be before "18F")' ,
'README.md: Company is listed out of order: "&yet" (should be before "17hats")' ,
] ,
} ) ;
} ) ;
it ( 'should catch invalid profile links and missing profiles' , ( ) => {
2018-06-25 05:00:12 +00:00
expectValidateFixturesResult ( 'bad-profile-links' , {
errorCount : 4 ,
2018-06-23 04:50:06 +00:00
output : [
2019-10-14 18:14:56 +00:00
'README.md: Invalid link to company profile for "&yet": "company-profiles/and-yet.md"' ,
'README.md: Missing company profile for "17hats", or broken link: "/company-profiles/17hats-nonexistent.md"' ,
'README.md: Invalid link to company profile for "18F": "/company-profiles/18f.js"' ,
'README.md: Company "My awesome company" has no linked Markdown profile ("/company-profiles/my-awesome-company.md")' ,
2018-06-23 04:50:06 +00:00
] ,
} ) ;
} ) ;
it ( 'should catch invalid titles in company profiles' , ( ) => {
2018-06-25 05:00:12 +00:00
expectValidateFixturesResult ( 'bad-profile-titles' , {
errorCount : 7 ,
2018-06-23 04:50:06 +00:00
output : [
'10up.md: Expected 1 first-level heading but found 0' ,
'10up.md: The main title is wrapped inside of another element.' ,
'10up.md: Company name looks wrong: ""' ,
2019-01-08 01:40:24 +00:00
'17hats.md: Company title "A company called 17hats" doesn\'t match filename (expected ~ "a-company-called-17hats.md")' ,
2019-11-01 03:37:35 +00:00
'18f.md: Company name looks wrong: "$%$#%$#"' ,
2018-06-23 04:50:06 +00:00
'and-yet.md: Expected 1 first-level heading but found 2' ,
2019-01-08 01:40:24 +00:00
'let-s-encrypt.md: Company title "Let\'s Encrypt" doesn\'t match filename (expected ~ "lets-encrypt.md")' ,
2018-06-23 04:50:06 +00:00
] ,
} ) ;
} ) ;
it ( 'should catch orphaned company profiles' , ( ) => {
2018-06-25 05:00:12 +00:00
expectValidateFixturesResult ( 'orphaned-profiles' , {
errorCount : 1 ,
2018-06-23 04:50:06 +00:00
output : [
'18f.md: No link to company profile from readme' ,
] ,
} ) ;
} ) ;
it ( 'should catch invalid section headings' , ( ) => {
2018-06-25 05:00:12 +00:00
expectValidateFixturesResult ( 'bad-profile-headings' , {
errorCount : 10 ,
2018-06-23 04:50:06 +00:00
output : [
'10up.md: Required section "Company blurb" not found.' ,
'17hats.md: Invalid section: "A thing I made up". Expected one of: ["Company blurb","Company size","Remote status","Region","Company technologies","Office locations","How to apply"]' ,
'17hats.md: Content is not part of any section: <p>Some extra content.</p>' ,
'18f.md: Duplicate section: "Company size".' ,
2018-06-25 07:16:13 +00:00
'18f.md: Empty section: "Region". Fill it in or leave it out instead.' ,
'18f.md: Empty section: "Remote status". Fill it in or leave it out instead.' ,
2018-06-23 04:50:06 +00:00
'1password.md: The main title is wrapped inside of another element.' ,
'1password.md: The section heading for "Company size" is wrapped inside of another element.' ,
'1password.md: Content is not part of any section: <blockquote><h1 id="1password">1Password</h1></blockquote>' ,
'and-yet.md: Required section "Company blurb" not found.' ,
] ,
} ) ;
} ) ;
2018-06-25 02:42:33 +00:00
it ( 'should catch text outside of links in readme' , ( ) => {
2018-06-25 05:00:12 +00:00
expectValidateFixturesResult ( 'name-outside-link' , {
errorCount : 3 ,
2018-06-25 02:42:33 +00:00
output : [
'README.md: Extra text in company name: "10up", "10up agency"' ,
'README.md: Extra text in company name: "Aerolab", "Aerolab more text"' ,
'README.md: Extra text in company name: "AngularClass", "AngularClass text"' ,
] ,
} ) ;
} ) ;
it ( 'should catch mismatched "incomplete profile" indicators' , ( ) => {
2018-06-25 05:00:12 +00:00
expectValidateFixturesResult ( 'mismatched-incomplete-indicators' , {
2018-06-25 07:16:13 +00:00
errorCount : 9 ,
2018-06-25 02:42:33 +00:00
output : [
'10up.md: Profile is marked as complete, but it only contains a "Company blurb" heading.' ,
'17hats.md: Profile looks complete, but the "Company blurb" contains a warning emoji.' ,
'18f.md: Profile looks incomplete, but the main readme does not contain a warning emoji.' ,
2018-06-25 05:00:12 +00:00
(
'45royale.md: Profile is marked as incomplete, but it contains multiple sections.'
+ '\nPlease remove the warning emoji from the "Company blurb" section and the main readme.'
) ,
2018-06-25 02:42:33 +00:00
'aerolab.md: Profile looks incomplete, but the "Company blurb" does not contain a warning emoji.' ,
'and-yet.md: Profile looks complete, but the main readme contains a warning emoji.' ,
'angularclass.md: Profile looks incomplete, but the "Company blurb" does not contain a warning emoji.' ,
2018-06-25 07:16:13 +00:00
'anomali.md: Invalid section: "Invalid section name". Expected one of: ["Company blurb","Company size","Remote status","Region","Company technologies","Office locations","How to apply"]' ,
'anomali.md: Required section "Company blurb" not found.' ,
2018-06-25 02:42:33 +00:00
] ,
} ) ;
} ) ;
2018-06-23 04:50:06 +00:00
} ) ;