-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mockProperty): make sure a falsy value can be assigned to a mock …
…property (#208)
- Loading branch information
Showing
3 changed files
with
83 additions
and
3 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
49 changes: 49 additions & 0 deletions
49
test/transformer/descriptor/properties/assignFalsy.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,49 @@ | ||
import { createMock } from 'ts-auto-mock'; | ||
|
||
describe('mocking properties', () => { | ||
describe('when property is a mock', () => { | ||
interface SubInterface { | ||
aProp: string; | ||
} | ||
|
||
interface AnInterface { | ||
bProp: SubInterface; | ||
} | ||
|
||
it('should correctly assign null', () => { | ||
const anInterface: AnInterface = createMock<AnInterface>(); | ||
|
||
anInterface.bProp = null; | ||
|
||
expect(anInterface.bProp).toBeNull(); | ||
}); | ||
}); | ||
|
||
describe('when property is a value type', () => { | ||
interface AnInterface { | ||
aProp: string; | ||
} | ||
|
||
it('should correctly assign null', () => { | ||
const anInterface: AnInterface = createMock<AnInterface>(); | ||
|
||
anInterface.aProp = null; | ||
|
||
expect(anInterface.aProp).toBeNull(); | ||
}); | ||
}); | ||
|
||
describe('when property is a function', () => { | ||
interface AnInterface { | ||
aProp(): string; | ||
} | ||
|
||
it('should correctly assign null', () => { | ||
const anInterface: AnInterface = createMock<AnInterface>(); | ||
|
||
anInterface.aProp = null; | ||
|
||
expect(anInterface.aProp).toBeNull(); | ||
}); | ||
}); | ||
}); |