Skip to content

Commit

Permalink
Merge pull request #119 from pliancy/refactor/modularize
Browse files Browse the repository at this point in the history
chore(project): modernize & return customer features from Egnyte
  • Loading branch information
noticeeverything authored Mar 21, 2024
2 parents 4c54e53 + c565f3f commit 5ea2d39
Show file tree
Hide file tree
Showing 17 changed files with 965 additions and 627 deletions.
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = {
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
moduleNameMapper: {
'axios': 'axios/dist/node/axios.cjs'
}
axios: 'axios/dist/node/axios.cjs',
},
}
57 changes: 57 additions & 0 deletions src/index.spec.ts
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()
})
}
}
}
}
})
120 changes: 0 additions & 120 deletions src/index.test.ts

This file was deleted.

Loading

0 comments on commit 5ea2d39

Please sign in to comment.