Skip to content

Commit

Permalink
replace store mock in unit test by the real store
Browse files Browse the repository at this point in the history
  • Loading branch information
jparez committed Jan 27, 2025
1 parent cce1513 commit 82b960b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 20 deletions.
13 changes: 3 additions & 10 deletions tests/mocks/DeviceRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const Original = require('../../src/DeviceRenderer');
const OriginalToolbarManager = require('../../src/plugins/util/ToolBarManager');
const store = require('../../src/store/index');

class ToolBarManager extends OriginalToolbarManager {
constructor() {
Expand Down Expand Up @@ -44,20 +45,12 @@ module.exports = class DeviceRenderer extends Original {

super(document.body, options || {});
this.outgoingMessages = [];
this.store = {
getState: () => {
return {};
},
subscribe: jest.fn(),
dispatch: jest.fn(),
getters: {
isWidgetOpened: () => false,
},
};
this.apiManager = {
registerFunction: jest.fn(),
};
this.toolbarManager = new ToolBarManager();
// Load store since it's deviceRendererFactory which load it
store(this);
}

/**
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/apiManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const ApiManager = require('../../src/APIManager');
const Instance = require('../mocks/DeviceRenderer');
const Clipboard = require('../../src/plugins/Clipboard');
const store = require('../../src/store/index');

let apiManager;
let instance;
Expand All @@ -14,7 +13,6 @@ describe('APIManager', () => {
instance = new Instance({});
apiManager = new ApiManager(instance);
exposedApiFunctions = apiManager.getExposedApiFunctions();
store(instance);

new Clipboard(instance, {
CLIPBOARD_TITLE: 'TEST CLIPBOARD PLUGIN TITLE',
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/clipboard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ jest.mock('loglevel');

const Clipboard = require('../../src/plugins/Clipboard');
const Instance = require('../mocks/DeviceRenderer');
const store = require('../../src/store/index');

let clipboard;
let instance;
Expand All @@ -13,7 +12,6 @@ let plugin;
describe('Clipboard Plugin', () => {
beforeEach(() => {
instance = new Instance();
store(instance);
clipboard = new Clipboard(instance, {});
plugin = document.getElementsByClassName('gm-clipboard-plugin')[0];
});
Expand All @@ -27,7 +25,6 @@ describe('Clipboard Plugin', () => {
describe('UI', () => {
beforeEach(() => {
instance = new Instance();
store(instance);
clipboard = new Clipboard(instance, {
CLIPBOARD_TITLE: 'TEST CLIPBOARD PLUGIN TITLE',
});
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/fileupload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
jest.mock('loglevel');
const FileUpload = require('../../src/plugins/FileUpload');
const Instance = require('../mocks/DeviceRenderer');
const store = require('../../src/store/index');

let uploader;
let instance;
Expand All @@ -11,7 +10,6 @@ let plugin;
describe('FileUpload Plugin', () => {
beforeEach(() => {
instance = new Instance();
store(instance);

uploader = new FileUpload(instance, {
UPLOADER_INSTALLING: 'TEST UPLOADER PLUGIN INSTALLING...',
Expand All @@ -34,7 +32,6 @@ describe('FileUpload Plugin', () => {
describe('UI', () => {
beforeEach(() => {
instance = new Instance();
store(instance);
uploader = new FileUpload(instance, {
UPLOADER_TITLE: 'TEST UPLOADER PLUGIN TITLE',
UPLOADER_HOME_TITLE: 'TEST UPLOADER PLUGIN HOME TITLE',
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/fingerprint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ jest.mock('loglevel');

const FingerPrint = require('../../src/plugins/FingerPrint');
const Instance = require('../mocks/DeviceRenderer');
const store = require('../../src/store/index');

let instance;

Expand All @@ -13,7 +12,6 @@ describe('FingerPrint Plugin', () => {
instance = new Instance({
giveFeedbackLink: 'https://github.com/orgs/Genymobile/discussions',
});
store(instance);
new FingerPrint(instance, {}, true);
});

Expand Down

0 comments on commit 82b960b

Please sign in to comment.