Skip to content

Commit

Permalink
Setting up original find-specs.spec.js file, grabbed from `design-s…
Browse files Browse the repository at this point in the history
…ystem`.
  • Loading branch information
erinesullivan committed Feb 21, 2025
1 parent 5ba23a5 commit f443af2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/find-specs.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { expect } from 'chai';
import fs from 'fs';

const deepSearch = (path) => {
fs.readdirSync(path).forEach((listing) => {
const listingPath = `${path}/${listing}`;
// Keep searching until the current listing is not a directory
if (!listing.includes('.')) {
deepSearch(listingPath);
}
// Check if current listing is a JavaScript file
if (listing.endsWith('.js')) {
// Convert current listing path into matching spec path
let specPath = path.split('/');
specPath[0] = 'test';
specPath = `${specPath.join('/')}/${listing.slice(0, -3)}.spec.js`;
// Return test to see if the spec exists
it(`'${listingPath}' has a spec file ('${specPath}')`, function () {
expect(fs.existsSync(`${specPath}`)).to.be.true;
});
}
});
};

describe('checks if component files have associated specs', function () {
deepSearch('assets/scripts');

Check failure on line 26 in test/find-specs.spec.js

View workflow job for this annotation

GitHub Actions / test-js

Unexpected function call in describe block
});

0 comments on commit f443af2

Please sign in to comment.