From a8a6577cd7aea2fea96a1ac28a4857526517b60f Mon Sep 17 00:00:00 2001 From: Nito Buendia Date: Thu, 17 Mar 2022 20:16:22 +0800 Subject: [PATCH] Replace parameterized test with different expectations This approach makes it hard to scale and goes against DRY and debuggability vs the previous approach which followed Python parameterized testing, but this was the recommendation of the Jasmine team to keep it consistent with other tests. Further tests here could be adding other types like Array, Map, WeakMap, Set, WeakSet... --- .../matchers/toHaveSpyInteractionsSpec.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/spec/core/matchers/toHaveSpyInteractionsSpec.js b/spec/core/matchers/toHaveSpyInteractionsSpec.js index 80d4b700..2a7bb436 100755 --- a/spec/core/matchers/toHaveSpyInteractionsSpec.js +++ b/spec/core/matchers/toHaveSpyInteractionsSpec.js @@ -60,14 +60,20 @@ describe('toHaveSpyInteractions', function() { ); }); - [true, 123, 'string'].forEach(function(testValue) { - it(`throws error if a non-object (${testValue}) is passed`, function() { - let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); + it(`throws error if a non-object is passed`, function() { + let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); - expect(function() { - matcher.compare(testValue); - }).toThrowError(Error, /Expected a spy object, but got/); - }); + expect(function() { + matcher.compare(true); + }).toThrowError(Error, /Expected a spy object, but got/); + + expect(function () { + matcher.compare(123); + }).toThrowError(Error, /Expected a spy object, but got/); + + expect(function () { + matcher.compare('string'); + }).toThrowError(Error, /Expected a spy object, but got/); }); it('throws error if arguments are passed', function() {