-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from pliancy/refactor/modularize
chore(project): modernize & return customer features from Egnyte
- Loading branch information
Showing
17 changed files
with
965 additions
and
627 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { readdirSync, readFileSync } from 'node:fs' | ||
|
||
describe('IndexBarrel', () => { | ||
const base = './src/lib' | ||
|
||
// Our exports from index.ts | ||
const exports = readFileSync('./src/index.ts', 'utf-8').split('\n') | ||
|
||
// loop directories in ./lib | ||
const directories = readdirSync(base) | ||
for (const directory of directories) { | ||
const isRootTypesFile = directory === 'types.ts' | ||
const isRootExport = directory === 'egnyte.ts' | ||
|
||
// ignore files at the root of ./lib except types.ts | ||
if (!isRootTypesFile && !isRootExport && /\.ts/.test(directory)) continue | ||
|
||
// ensure we've exported base types | ||
if (isRootTypesFile) { | ||
it(`exports types.ts from ${directory}`, () => | ||
expect(exports.find((e) => e === `export * from './lib/types'`)).toBeTruthy()) | ||
} else if (isRootExport) { | ||
it(`exports egnyte.ts from ${directory}`, () => | ||
expect( | ||
exports.find((e) => e === `export { Egnyte } from './lib/egnyte'`), | ||
).toBeTruthy()) | ||
} else { | ||
// loop all files in directory | ||
const files = readdirSync(`${base}/${directory}`) | ||
for (const file of files) { | ||
// ignore tests | ||
if (/\.spec/.test(file)) continue | ||
|
||
// get file name without extension | ||
const fileWithoutExt = file.replace('.ts', '') | ||
|
||
// get class name (e.g., mdm-configurations => mdmconfigurations) | ||
const cls = fileWithoutExt.replace('-', '') | ||
|
||
// ensure all types and classes are exported | ||
if (/\.types/.test(file)) { | ||
it(`exports ${file} from ${directory}`, () => | ||
expect( | ||
exports.find( | ||
(e) => e === `export * from './lib/${directory}/${fileWithoutExt}'`, | ||
), | ||
).toBeTruthy()) | ||
} else { | ||
it(`exports ${file} from ${directory}`, () => { | ||
const exp = `export { ${cls} } from './lib/${directory}/${fileWithoutExt}'` | ||
expect(exports.find((e) => e.toLowerCase() === exp)).toBeTruthy() | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
}) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.