From b235ca4fe763f2e9f347f3fa5b9f1510d5cf0567 Mon Sep 17 00:00:00 2001 From: Jacob Trimble Date: Wed, 19 Jun 2019 15:51:34 -0700 Subject: [PATCH] Favor expect.not.toHaveBeenCalled. Change-Id: I7009ff69bfca5ef8a38bcdff73a16a02cfa205b1 --- .eslintrc.js | 6 ++++++ test/dash/dash_parser_live_unit.js | 2 +- test/media/region_timeline_unit.js | 2 +- test/media/streaming_engine_unit.js | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index dbba6936c4..c8600282d1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -216,6 +216,12 @@ module.exports = { '[callee.object.property.name=calls]', 'message': 'Use expect.toHaveBeenCalledTimes', }, + { + 'selector': + 'CallExpression[callee.property.name=toHaveBeenCalledTimes] >' + + 'Literal[value=0]', + 'message': 'Use expect.not.toHaveBeenCalled', + }, ...commonNoRestrictedSyntax, ], }, diff --git a/test/dash/dash_parser_live_unit.js b/test/dash/dash_parser_live_unit.js index 74523b5885..b92fabc34e 100644 --- a/test/dash/dash_parser_live_unit.js +++ b/test/dash/dash_parser_live_unit.js @@ -368,7 +368,7 @@ describe('DashParser Live', () => { expect(manifest.periods.length).toBe(1); // Should call filterAllPeriods for parsing the first manifest - expect(filterNewPeriod).toHaveBeenCalledTimes(0); + expect(filterNewPeriod).not.toHaveBeenCalled(); expect(filterAllPeriods).toHaveBeenCalledTimes(1); fakeNetEngine.setResponseText('dummy://foo', secondManifest); diff --git a/test/media/region_timeline_unit.js b/test/media/region_timeline_unit.js index c95673e7aa..adfec59e71 100644 --- a/test/media/region_timeline_unit.js +++ b/test/media/region_timeline_unit.js @@ -44,7 +44,7 @@ describe('RegionTimeline', () => { const differentEndTime = createRegion('my-region', 0, 5); // Make sure we are starting from a blank slate. - expect(onNewRegion).toHaveBeenCalledTimes(0); + expect(onNewRegion).not.toHaveBeenCalled(); // When we add a region, we should get an event. timeline.addRegion(initialRegion); diff --git a/test/media/streaming_engine_unit.js b/test/media/streaming_engine_unit.js index ed1037c41c..db894405e1 100644 --- a/test/media/streaming_engine_unit.js +++ b/test/media/streaming_engine_unit.js @@ -2077,7 +2077,7 @@ describe('StreamingEngine', () => { runTest(); expect(onError).toHaveBeenCalledTimes(1); expect(netEngine.attempts).toBe(1); - expect(mediaSourceEngine.endOfStream).toHaveBeenCalledTimes(0); + expect(mediaSourceEngine.endOfStream).not.toHaveBeenCalled(); }); it('does not invoke the callback if the error is handled', () => {