From 2a4504a81dd8a256d17dcfba4f899ca692c72805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=CC=81rio=20Gonc=CC=A7alves?= Date: Thu, 15 Feb 2018 12:06:32 +0000 Subject: [PATCH] Added test cases --- types/jest/jest-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index 4d8ae05e1c..4c37f2bb65 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -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 `