-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
glob()
for all directory listings
- Loading branch information
1 parent
1d58417
commit 2e1de86
Showing
13 changed files
with
286 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,58 @@ | ||
const glob = require('glob') | ||
const path = require('path') | ||
const { join } = require('path') | ||
|
||
const sassdoc = require('sassdoc') | ||
|
||
const { getListing } = require('../../../lib/file-helper') | ||
const { renderSass } = require('../../../lib/jest-helpers') | ||
const configPaths = require('../../../config/paths.js') | ||
|
||
const sassFiles = glob.sync(`${configPaths.src}/helpers/**/*.scss`) | ||
|
||
describe('The helpers layer', () => { | ||
let sassFiles | ||
|
||
beforeAll(async () => { | ||
sassFiles = await getListing(configPaths.src, 'helpers/**/*.scss', { | ||
ignore: ['**/_all.scss'] | ||
}) | ||
}) | ||
|
||
it('should not output any CSS', async () => { | ||
const helpers = path.join(configPaths.src, 'helpers', '_all.scss') | ||
const helpers = join(configPaths.src, 'helpers', '_all.scss') | ||
|
||
const output = await renderSass({ file: helpers }) | ||
expect(output.css.toString()).toEqual('') | ||
}) | ||
|
||
it.each(sassFiles)('%s renders to CSS without errors', (file) => { | ||
return renderSass({ file }) | ||
it('renders CSS for all helpers', () => { | ||
const sassTasks = sassFiles.map((sassFilePath) => { | ||
const file = join(configPaths.src, sassFilePath) | ||
|
||
return expect(renderSass({ file })).resolves.toEqual( | ||
expect.objectContaining({ | ||
css: expect.any(Object), | ||
stats: expect.any(Object) | ||
}) | ||
) | ||
}) | ||
|
||
return Promise.all(sassTasks) | ||
}) | ||
|
||
describe('Sass documentation', () => { | ||
it('associates everything with a "helpers" group', async () => { | ||
return sassdoc.parse(path.join(configPaths.src, 'helpers', '*.scss')) | ||
.then(docs => docs.forEach(doc => { | ||
return expect(doc).toMatchObject({ | ||
// Include doc.context.name in the expected result when this fails, | ||
// giving you the context to be able to fix it | ||
context: { | ||
name: doc.context.name | ||
}, | ||
group: [ | ||
expect.stringMatching(/^helpers/) | ||
] | ||
}) | ||
})) | ||
const docs = await sassdoc.parse(join(configPaths.src, 'helpers', '*.scss')) | ||
|
||
for (const doc of docs) { | ||
expect(doc).toMatchObject({ | ||
// Include doc.context.name in the expected result when this fails, | ||
// giving you the context to be able to fix it | ||
context: { | ||
name: doc.context.name | ||
}, | ||
group: [ | ||
expect.stringMatching(/^helpers/) | ||
] | ||
}) | ||
} | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.