Skip to content

Commit

Permalink
Update dependency eslint-plugin-jest to v27 (#239)
Browse files Browse the repository at this point in the history
* Update dependency eslint-plugin-jest to v27

* Fix linter issues

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Luiz Ferraz <luiz@lferraz.com>
  • Loading branch information
renovate[bot] and Fryuni authored Sep 28, 2022
1 parent 867ac3a commit b48ba41
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 56 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"eslint": "^8.0.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.0.0",
"eslint-plugin-jest": "^27.0.0",
"fetch-mock": "^9.11.0",
"jest": "^26.6.3",
"jest-websocket-mock": "^2.3.0",
Expand Down
20 changes: 10 additions & 10 deletions test/cache/fallbackCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ describe('An fallback cache', () => {

expect(cache.get()).toBeNull();

expect(firstCache.get).toBeCalledTimes(1);
expect(secondCache.get).toBeCalledTimes(1);
expect(firstCache.get).toHaveBeenCalledTimes(1);
expect(secondCache.get).toHaveBeenCalledTimes(1);

expect(cache.get()).toBe('foo');

expect(firstCache.get).toBeCalledTimes(2);
expect(secondCache.get).toBeCalledTimes(1);
expect(firstCache.get).toHaveBeenCalledTimes(2);
expect(secondCache.get).toHaveBeenCalledTimes(1);
});

test('should store data into all underlying caches', async () => {
Expand All @@ -46,10 +46,10 @@ describe('An fallback cache', () => {

cache.put('bar');

expect(firstCache.put).toBeCalledTimes(1);
expect(firstCache.put).toBeCalledWith('bar');
expect(secondCache.put).toBeCalledTimes(1);
expect(secondCache.put).toBeCalledWith('bar');
expect(firstCache.put).toHaveBeenCalledTimes(1);
expect(firstCache.put).toHaveBeenCalledWith('bar');
expect(secondCache.put).toHaveBeenCalledTimes(1);
expect(secondCache.put).toHaveBeenCalledWith('bar');
});

test('should clear all underlying caches', async () => {
Expand All @@ -69,7 +69,7 @@ describe('An fallback cache', () => {

cache.clear();

expect(firstCache.clear).toBeCalledTimes(1);
expect(secondCache.clear).toBeCalledTimes(1);
expect(firstCache.clear).toHaveBeenCalledTimes(1);
expect(secondCache.clear).toHaveBeenCalledTimes(1);
});
});
4 changes: 2 additions & 2 deletions test/channel/encodedChannel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ describe('An encoded channel', () => {
test('should encode and then publish the message', async () => {
await channel.publish('ping');

expect(outputChannel.publish).toBeCalledWith('ping-pong');
expect(outputChannel.publish).toHaveBeenCalledWith('ping-pong');
});

test('should close the output channel on close', async () => {
await channel.close();

expect(outputChannel.close).toBeCalled();
expect(outputChannel.close).toHaveBeenCalled();
});
});
2 changes: 1 addition & 1 deletion test/channel/retryChannel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ describe('A retry channel', () => {

await channel.close();

expect(outputChannel.close).toBeCalled();
expect(outputChannel.close).toHaveBeenCalled();
});
});
6 changes: 3 additions & 3 deletions test/channel/socketChannel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('A socket channel', () => {
socket.close({code: 1011, reason: 'Server error', wasClean: false});
});

await expect(channel.publish('foo')).rejects.toThrowError();
await expect(channel.publish('foo')).rejects.toThrow();
});

test('should reconnect if the connection cannot be established', async () => {
Expand All @@ -59,7 +59,7 @@ describe('A socket channel', () => {
attempt += 1;
});

await expect(channel.publish('foo')).rejects.toThrowError();
await expect(channel.publish('foo')).rejects.toThrow();
await expect(channel.publish('bar')).resolves.toBeUndefined();
});

Expand Down Expand Up @@ -209,7 +209,7 @@ describe('A socket channel', () => {
test('should close connection with error', async () => {
const channel = new SocketChannel({url: url});

await expect(channel.publish('open connection')).rejects.toThrowError();
await expect(channel.publish('open connection')).rejects.toThrow();

await expect(channel.close()).resolves.toBeUndefined();
});
Expand Down
2 changes: 1 addition & 1 deletion test/container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ test('should flush the beacon queue on initialization', async () => {
const promise = tracker.track(payload);

await container.dispose();
await expect(promise).rejects.toThrowError();
await expect(promise).rejects.toThrow();

const server = new WS(`${configuration.trackerEndpointUrl}/${configuration.appId}`, {jsonProtocol: true});

Expand Down
34 changes: 17 additions & 17 deletions test/facade/sdkFacade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('A SDK facade', () => {

SdkFacade.init({appId: appId});

expect(initialize).toBeCalledWith({
expect(initialize).toHaveBeenCalledWith({
appId: appId,
tokenScope: 'global',
debug: false,
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('A SDK facade', () => {
urlSanitizer: urlSanitizer,
});

expect(initialize).toBeCalledWith({
expect(initialize).toHaveBeenCalledWith({
appId: appId,
trackerEndpointUrl: 'https://api.croct.io/tracker',
evaluationEndpointUrl: 'https://api.croct.io/evaluation',
Expand Down Expand Up @@ -134,8 +134,8 @@ describe('A SDK facade', () => {
track: false,
});

expect(context.setToken).toBeCalledWith(carolToken);
expect(context.setToken).toBeCalledTimes(1);
expect(context.setToken).toHaveBeenCalledWith(carolToken);
expect(context.setToken).toHaveBeenCalledTimes(1);
});

test('should load the SDK and unset any existing token', () => {
Expand All @@ -158,7 +158,7 @@ describe('A SDK facade', () => {
track: false,
});

expect(context.setToken).toBeCalledWith(null);
expect(context.setToken).toHaveBeenCalledWith(null);
});

test('should load the SDK and set a token for the provided user ID', () => {
Expand All @@ -183,8 +183,8 @@ describe('A SDK facade', () => {
track: false,
});

expect(context.setToken).toBeCalledWith(Token.issue(appId, 'c4r0l'));
expect(context.setToken).toBeCalledTimes(1);
expect(context.setToken).toHaveBeenCalledWith(Token.issue(appId, 'c4r0l'));
expect(context.setToken).toHaveBeenCalledTimes(1);
});

test('should load the SDK with the tracker enabled if the flag "track" is true', () => {
Expand All @@ -205,7 +205,7 @@ describe('A SDK facade', () => {
track: true,
});

expect(tracker.enable).toBeCalledTimes(1);
expect(tracker.enable).toHaveBeenCalledTimes(1);
});

test('should load the SDK with the tracker disabled if the flag "track" is false', () => {
Expand Down Expand Up @@ -322,7 +322,7 @@ describe('A SDK facade', () => {
await expect(sdkFacade.evaluator.evaluate('1 + 1', {timeout: 5})).resolves.toBe(result);

expect(evaluator.evaluate).toHaveBeenCalledWith('1 + 1', expect.objectContaining({timeout: 5}));
expect(evaluator.evaluate).toBeCalledTimes(1);
expect(evaluator.evaluate).toHaveBeenCalledTimes(1);
});

test('should provide the context', () => {
Expand Down Expand Up @@ -369,8 +369,8 @@ describe('A SDK facade', () => {

sdkFacade.identify('c4r0l');

expect(context.setToken).toBeCalledWith(Token.issue(appId, 'c4r0l'));
expect(context.setToken).toBeCalledTimes(1);
expect(context.setToken).toHaveBeenCalledWith(Token.issue(appId, 'c4r0l'));
expect(context.setToken).toHaveBeenCalledTimes(1);
});

test('should allow anonymizing a user', () => {
Expand Down Expand Up @@ -423,7 +423,7 @@ describe('A SDK facade', () => {

sdkFacade.unsetToken();

expect(context.setToken).toBeCalledTimes(0);
expect(context.setToken).toHaveBeenCalledTimes(0);

sdkFacade.setToken(Token.issue(appId, 'c4r0l'));

Expand Down Expand Up @@ -453,8 +453,8 @@ describe('A SDK facade', () => {

sdkFacade.setToken(carolToken);

expect(context.setToken).toBeCalledWith(carolToken);
expect(context.setToken).toBeCalledTimes(1);
expect(context.setToken).toHaveBeenCalledWith(carolToken);
expect(context.setToken).toHaveBeenCalledTimes(1);
});

test('should provide the current token', () => {
Expand Down Expand Up @@ -517,7 +517,7 @@ describe('A SDK facade', () => {

expect(sdkFacade.getToken()).toEqual(newToken);

expect(tracker.track).toBeCalledTimes(0);
expect(tracker.track).toHaveBeenCalledTimes(0);
});

test('should allow to refresh the token of the current identified user', () => {
Expand Down Expand Up @@ -558,8 +558,8 @@ describe('A SDK facade', () => {

expect(sdkFacade.getToken()).toEqual(newCarolToken);

expect(tracker.track).toBeCalledTimes(1);
expect(tracker.track).toBeCalledWith({
expect(tracker.track).toHaveBeenCalledTimes(1);
expect(tracker.track).toHaveBeenCalledWith({
type: 'userSignedIn',
userId: 'c4r0l',
});
Expand Down
8 changes: 4 additions & 4 deletions test/queue/monitoredQueue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('A monitored queue', () => {

queue.addCallback(status, callback);

expect(callback).toBeCalledWith(queue);
expect(callback).toHaveBeenCalledWith(queue);
});

test('should allow to remove a callback', () => {
Expand All @@ -143,8 +143,8 @@ describe('A monitored queue', () => {
queue.removeCallback('full', callback);
queue.push('bar');

expect(callback).toBeCalledWith(queue);
expect(callback).toBeCalledTimes(1);
expect(callback).toHaveBeenCalledWith(queue);
expect(callback).toHaveBeenCalledTimes(1);
});

test('should not fail to remove an nonexistent callback', () => {
Expand All @@ -154,6 +154,6 @@ describe('A monitored queue', () => {
queue.removeCallback('full', callback);
queue.push('foo');

expect(callback).not.toBeCalled();
expect(callback).not.toHaveBeenCalled();
});
});
2 changes: 1 addition & 1 deletion test/schemas/loggerSchema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('The logger schema', () => {
extra: true,
};

expect(() => loggerSchema.validate(logger)).not.toThrowError();
expect(() => loggerSchema.validate(logger)).not.toThrow();
});

test.each([
Expand Down
12 changes: 6 additions & 6 deletions test/tracker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ describe('A tracker', () => {

tracker.suspend();

await expect(tracker.track(event, 1)).rejects.toThrowError();
await expect(tracker.track(event, 1)).rejects.toThrow();

tracker.unsuspend();

await expect(tracker.track(event, 2)).resolves.toBeDefined();

await expect(tracker.track(event, 3)).rejects.toThrowError();
await expect(tracker.track(event, 3)).rejects.toThrow();

// Listeners can be added more than once, should remove both
tracker.addListener(listener);
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('A tracker', () => {
...eventInfo,
});

expect(listener).toBeCalledTimes(5);
expect(listener).toHaveBeenCalledTimes(5);
});

test('should allow to be enabled even if it is suspended', () => {
Expand Down Expand Up @@ -389,7 +389,7 @@ describe('A tracker', () => {
sinceTime: 0,
});

expect(channel.publish).toBeCalledWith(
expect(channel.publish).toHaveBeenCalledWith(
expect.objectContaining({
context: expect.objectContaining({
metadata: metadata,
Expand Down Expand Up @@ -421,7 +421,7 @@ describe('A tracker', () => {
sinceTime: 0,
});

expect(channel.publish).toBeCalledWith(
expect(channel.publish).toHaveBeenCalledWith(
expect.objectContaining({
token: token.toString(),
}),
Expand Down Expand Up @@ -1248,7 +1248,7 @@ describe('A tracker', () => {

await expect(tracker.flushed).resolves.toBeUndefined();

expect(publish).toBeCalledWith({
expect(publish).toHaveBeenCalledWith({
timestamp: now,
context: {
tabId: tab.id,
Expand Down
2 changes: 1 addition & 1 deletion test/validation/jsonType.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('A JSON object type', () => {
objectType.validate({foobar: 'baz'});
}

expect(validateValidValue).not.toThrowError();
expect(validateValidValue).not.toThrow();
expect(validateInvalidValue).toThrow(Error);
expect(validateInvalidValue).toThrow('Expected at most 3 characters at path \'/foobar\', actual 6.');
});
Expand Down

0 comments on commit b48ba41

Please sign in to comment.