Skip to content

Commit

Permalink
fix fingerprint TU by adding a mock for the store
Browse files Browse the repository at this point in the history
  • Loading branch information
jparez committed Feb 20, 2024
1 parent 7693312 commit 3fa45a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions tests/mocks/DeviceRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ module.exports = class DeviceRenderer extends Original {

super(document.body, options || {});
this.outgoingMessages = [];
this.store = {
getState: ()=>{

Check failure on line 37 in tests/mocks/DeviceRenderer.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing space before =>

Check failure on line 37 in tests/mocks/DeviceRenderer.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing space after =>
return {};
},
subscribe: jest.fn(),
};
}

/**
Expand Down
8 changes: 5 additions & 3 deletions tests/unit/fingerprint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ let instance;

describe('FingerPrint Plugin', () => {
beforeEach(() => {
instance = new Instance();
instance = new Instance({
giveFeedbackLink: "https://github.com/orgs/Genymobile/discussions"

Check failure on line 13 in tests/unit/fingerprint.test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Strings must use singlequote
});
new FingerPrint(instance, {}, true);
});

Expand Down Expand Up @@ -83,11 +85,11 @@ describe('FingerPrint Plugin', () => {

test('Auto validate fingerprint\'s request when auto validation is enabled', () => {
const sendEventSpy = jest.spyOn(instance, 'sendEvent');
expect(sendEventSpy).toHaveBeenCalledTimes(0);
const autoValidation = document
.querySelector('.gm-fingerprint-dialog-recognized-fp-by-default-status span');
autoValidation.click();

expect(sendEventSpy).toHaveBeenCalledTimes(0);
instance.emit('fingerprint', 'current_status scanning');
instance.emit('fingerprint', 'scan start');

Expand All @@ -98,7 +100,7 @@ describe('FingerPrint Plugin', () => {
expect(sendEventSpy).toHaveBeenCalledTimes(1);
expect(instance.outgoingMessages[0]).toEqual({
channel: 'fingerprint', messages: [
'scan recognized',
'set auto_recognize true',
],
});
sendEventSpy.mockRestore();
Expand Down

0 comments on commit 3fa45a3

Please sign in to comment.