-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: integration constants based on pr comments
- Loading branch information
Showing
5 changed files
with
44 additions
and
169 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
39 changes: 39 additions & 0 deletions
39
packages/analytics-js-common/__tests__/constants/integrations/constants.test.ts
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,39 @@ | ||
import { readdirSync, statSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
const BaseIntegrationDir = join(__dirname, '../../../src/constants/integrations'); | ||
describe('Integration Constants', () => { | ||
let allConstants: Record<string, string>; | ||
|
||
beforeAll(async () => { | ||
allConstants = await import(join(BaseIntegrationDir, 'Destinations')); | ||
}); | ||
|
||
const integrations = readdirSync(BaseIntegrationDir); | ||
integrations | ||
// Skip non integration folders | ||
.filter(dir => ['CommonIntegrationsConstant'].indexOf(dir) === -1) | ||
.filter(dir => statSync(join(BaseIntegrationDir, dir)).isDirectory()) | ||
.forEach(integration => { | ||
describe(`${integration} Integration`, () => { | ||
let integrationConstants: { NAME: string; DISPLAY_NAME: string }; | ||
|
||
beforeAll(async () => { | ||
const modulePath = join(BaseIntegrationDir, integration, 'constants'); | ||
integrationConstants = await import(modulePath); | ||
}); | ||
|
||
it('should have the same NAME as defined in Destination constants', () => { | ||
const { NAME } = integrationConstants; | ||
expect(NAME).toBeDefined(); | ||
expect(NAME).toEqual(allConstants[`${NAME}_NAME`]); | ||
}); | ||
|
||
it('should have the same DISPLAY_NAME as defined in Destination constants', () => { | ||
const { NAME, DISPLAY_NAME } = integrationConstants; | ||
expect(DISPLAY_NAME).toBeDefined(); | ||
expect(DISPLAY_NAME).toEqual(allConstants[`${NAME}_DISPLAY_NAME`]); | ||
}); | ||
}); | ||
}); | ||
}); |
167 changes: 0 additions & 167 deletions
167
packages/analytics-js-common/src/constants/Destinations.ts
This file was deleted.
Oops, something went wrong.
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