mirror of
https://github.com/remoteintech/remote-jobs
synced 2024-11-15 00:47:19 +00:00
dac8b04fc8
* Prevent duplicate company names
* Fix output indentation
* Search full profile content using lunr.js
* Remove extra stop words
This wasn't really working correctly - the stop word 'work' would leave
instances of 'working' and 'works' in the index for example.
* Change company name description from "Name" to "Company name"
* Pre-process query:
- Search for terms in AND mode, per
https://lunrjs.com/guides/searching.html#term-presence
- Discard non-alphanumeric characters from the search
- Better handling of contractions and searching for stop words
* Display search query and results in the console
* Add special search token: _incomplete
* Add a link to search for incomplete profiles
* Revert "Add a link to search for incomplete profiles"
This reverts commit f6384c90cb
.
* Add link to search documentation
* Improve search explanation appearance when it spans multiple lines
* Fix searching for contractions
Previously, searching for e.g. "don't" wasn't working correctly. After
trimming the contraction, "do" is a stop word, so it should be ignored.
* Improve "empty search" message
* Prefer matches other than "company name" in search excerpts
* Move inline scripts before external scripts
This probably doesn't matter right now due to the way the scripts are
currently structured, but it might matter one day and it's more logical
this way.
* Fix search engine index progress
* Improve script indentation
* I got 99 problems and they're all bots
* Update script exit code
When a Node.js error occurs the exit code is probably going to be 1, so
we should use a different code.
* Fix the tests
* Update documentation
This was wrong (out of date), but the correct version is obvious from
reading the code.
* Make download progress work in both Chrome and Firefox
See https://stackoverflow.com/a/32799706
72 lines
2 KiB
JavaScript
72 lines
2 KiB
JavaScript
const path = require( 'path' );
|
|
const fs = require( 'fs' );
|
|
const { spawnSync } = require( 'child_process' );
|
|
|
|
const { expect } = require( 'chai' );
|
|
|
|
const { parseFromDirectory } = require( '../../lib' );
|
|
|
|
const fixturesPath = path.join( __dirname, '..', 'fixtures' );
|
|
const validatePath = path.join( __dirname, '..', '..', 'bin', 'validate.js' );
|
|
|
|
/**
|
|
* Parse a content tree from a set of fixture files.
|
|
*/
|
|
exports.parseFixtures = dirName => {
|
|
return parseFromDirectory( path.join( fixturesPath, dirName ) );
|
|
};
|
|
|
|
/**
|
|
* Parse a content tree from a set of fixture files and verify that the
|
|
* resulting errors are as expected.
|
|
*/
|
|
exports.expectValidateFixturesResult = ( dirName, expected ) => {
|
|
const result = exports.parseFixtures( dirName );
|
|
if ( result.ok ) {
|
|
expect( result ).not.to.have.key( 'errors' );
|
|
} else {
|
|
expect( result.errors ).to.be.an( 'array' );
|
|
expect( result.errors.length ).to.be.greaterThan( 0 );
|
|
}
|
|
expect( expected.errorCount ).to.equal( ( result.errors || [] ).length );
|
|
expect( expected.output ).to.eql( ( result.errors || [] ).map( err => {
|
|
return err.filename + ': ' + err.message;
|
|
} ) );
|
|
return result;
|
|
};
|
|
|
|
/**
|
|
* Parse a content tree from a set of fixture files by running the validation
|
|
* script in a separate process, and return the resulting output.
|
|
*/
|
|
exports.runValidationScriptWithFixtures = ( dirName, env = {} ) => {
|
|
const result = spawnSync( process.execPath, [
|
|
validatePath,
|
|
path.join( fixturesPath, dirName ),
|
|
], { env } );
|
|
|
|
if ( result.error ) {
|
|
throw result.error;
|
|
}
|
|
|
|
expect( result.stderr.toString() ).to.equal( '' );
|
|
|
|
const output = result.stdout.toString().trim().split( '\n' );
|
|
const exitCode = result.status;
|
|
|
|
let errorSummary = output[ output.length - 1 ];
|
|
if ( output.length >= 2 ) {
|
|
expect( output[ output.length - 2 ] ).to.equal( '' );
|
|
output.splice( -2 );
|
|
} else {
|
|
output.splice( -1 );
|
|
}
|
|
|
|
if ( process.env.DUMP_OUTPUT ) {
|
|
output.forEach( s => {
|
|
console.log( "'%s',", s.replace( /('|\\)/g, "\\$1" ) );
|
|
} );
|
|
}
|
|
|
|
return { output, errorSummary, exitCode };
|
|
};
|