Download slate/support/fixtures.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/slate/support/fixtures.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/slate/support/fixtures.js
-
curl -L -o fixtures.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/slate/support/fixtures.js
1.46 kB
| import fs from 'fs' | |
| import { basename, extname, resolve } from 'path' | |
| export const fixtures = (...args) => { | |
| let fn = args.pop() | |
| let options = { skip: false } | |
| if (typeof fn !== 'function') { | |
| options = fn | |
| fn = args.pop() | |
| } | |
| const path = resolve(...args) | |
| const files = fs.readdirSync(path) | |
| const dir = basename(path) | |
| const d = options.skip ? describe.skip : describe | |
| d(dir, () => { | |
| for (const file of files) { | |
| const p = resolve(path, file) | |
| const stat = fs.statSync(p) | |
| if (stat.isDirectory()) { | |
| fixtures(path, file, fn) | |
| } | |
| if ( | |
| stat.isFile() && | |
| (file.endsWith('.js') || | |
| file.endsWith('.tsx') || | |
| file.endsWith('.ts')) && | |
| !file.endsWith('custom-types.ts') && | |
| !file.endsWith('type-guards.ts') && | |
| !file.startsWith('.') && | |
| // Ignoring `index.js` files allows us to use the fixtures directly | |
| // from the top-level directory itself, instead of only children. | |
| file !== 'index.js' | |
| ) { | |
| const name = basename(file, extname(file)) | |
| // This needs to be a non-arrow function to use `this.skip()`. | |
| it(`${name} `, function () { | |
| const module = require(p) | |
| if (module.skip) { | |
| this.skip() | |
| return | |
| } | |
| fn({ name, path, module }) | |
| }) | |
| } | |
| } | |
| }) | |
| } | |
| fixtures.skip = (...args) => { | |
| fixtures(...args, { skip: true }) | |
| } | |