forked from jaredpalmer/tsdx
-
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.
refactor: be more descriptive than "blah", "foo", "bar" in tests
- instead of random names (which are bad practice), be very explicit about what the variables _should_ be - also add comments to some of the regression tests that didn't have any to describe them - similarly, when testing dev only logging, say that directly - and, in this case, instead of using an unnecessary swear word - the third contributor PR to TSDX removed some similar swear words in the templates - these were changed to "boop" and now similarly changed to be more descriptive - which is better practice anyway, not encouraging bad practices via the templates, and should also be easier to understand for newcomers - similarly, intead of "blah" and "works" in template tests, actually describe what the tests do - similarly encourage better practices in the tests - also rename template tests from "blah.test.ts" to "index.test.ts" because they test "index.ts" and it's common convention to name them the same - and fix a leftover "describe('it')" in the react template when it should be "describe('Thing')" which the storybook template has - "it" is also confusing when used together with the Jest "it" global - could use something better than "Thing" as well (e.g. "SomeComponent"), but don't want to dig through and re-test the Storybook pieces right now
- Loading branch information
Showing
17 changed files
with
24 additions
and
20 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export const sum = (a: number, b: number) => { | ||
if ('development' === process.env.NODE_ENV) { | ||
console.log('boop'); | ||
console.log('dev only output'); | ||
} | ||
return a + b; | ||
}; |
4 changes: 2 additions & 2 deletions
4
templates/basic/test/blah.test.ts → templates/basic/test/index.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { sum } from '../src'; | ||
|
||
describe('blah', () => { | ||
it('works', () => { | ||
describe('sum', () => { | ||
it('adds two numbers together', () => { | ||
expect(sum(1, 1)).toEqual(2); | ||
}); | ||
}); |
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
File renamed without changes.
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 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
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,2 @@ | ||
// this just ensure a simple import works | ||
export const returnsTrue = () => true; |
7 changes: 4 additions & 3 deletions
7
test/e2e/fixtures/build-default/src/syntax/nullish-coalescing.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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// regression test for nullish coalescing syntax | ||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#nullish-coalescing | ||
|
||
const bar = () => {}; | ||
const foo = false; | ||
export const x = foo ?? bar(); | ||
const someFunc = () => {}; | ||
const someFalse = false; | ||
const shouldBeFalse = someFalse ?? someFunc(); |
4 changes: 3 additions & 1 deletion
4
test/e2e/fixtures/build-default/src/syntax/optional-chaining.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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// regression test for optional chaining syntax | ||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining | ||
|
||
export const foo = (foo?: { bar: string }) => foo?.bar || 'bar'; | ||
const someObj: { someOptionalString?: string } = {}; | ||
const shouldBeBar = someObj?.someOptionalString || 'bar'; |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export const sum = (a: number, b: number) => { | ||
if ('development' === process.env.NODE_ENV) { | ||
console.log('fuck'); | ||
console.log('dev only output'); | ||
} | ||
return a + b; | ||
}; |
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