Added test cases

This commit is contained in:
Mário Gonçalves
2018-02-15 12:06:32 +00:00
parent c52bfaf215
commit 2a4504a81d

View File

@@ -642,6 +642,22 @@ describe('rejects', () => {
});
});
// https://facebook.github.io/jest/docs/en/expect.html#tohavepropertykeypath-value
describe('toHaveProperty', () => {
it('it accepts a keyPath as string', () => {
expect({ a: { b: {}}}).toHaveProperty('a');
});
it('it accepts a keyPath as string with dot notation', () => {
expect({ a: { b: {}}}).toHaveProperty('a.b');
});
it('it accepts a keyPath as an array', () => {
expect({ a: { b: {}}}).toHaveProperty(['a', 'b']);
});
it('it accepts a keyPath as an array containing non-string values', () => {
expect({ a: ['b']}).toHaveProperty(['a', 0]);
});
});
class MyTransformer implements jest.Transformer {
process(text: string, path: string) {
return `