forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(config): migrate constants to TS (freeCodeCamp#51485)
- Loading branch information
1 parent
9885d1a
commit c071993
Showing
8 changed files
with
143 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import '@total-typescript/ts-reset'; |
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,26 @@ | ||
import { blocklistedUsernames } from './constants'; | ||
|
||
describe('constants', () => { | ||
describe('blocklistedUsernames', () => { | ||
it('should not contain duplicate values', () => { | ||
const uniqueValues = new Set(blocklistedUsernames); | ||
expect(blocklistedUsernames.length).toEqual(uniqueValues.size); | ||
}); | ||
|
||
it('should contain all the letters in the latin alphabet', () => { | ||
const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''); | ||
expect(blocklistedUsernames).toEqual(expect.arrayContaining(alphabet)); | ||
}); | ||
}); | ||
}); | ||
|
||
// Type tests: | ||
type BlocklistedUsernames = (typeof blocklistedUsernames)[number]; | ||
|
||
type HasString = string extends BlocklistedUsernames ? true : false; | ||
|
||
type Expect<T extends true> = T; | ||
|
||
// @ts-expect-error - This is intended to fail since we want to ensure that blocklistedUsernames is an array of literals | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
type Test = Expect<HasString>; |
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
Oops, something went wrong.