Skip to content

Commit

Permalink
test: fix test ordering and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stas-nc committed Dec 20, 2024
1 parent d787c16 commit 3556cff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
5 changes: 3 additions & 2 deletions ilc/client/BundleLoader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('BundleLoader', () => {
delete: sinon.stub(),
};
let registry;
let registryConfigurationStub;
const configRoot = getIlcConfigRoot();

const mockFactoryFn = () => {};
Expand Down Expand Up @@ -53,12 +54,12 @@ describe('BundleLoader', () => {
},
},
}).getConfig();

configRoot.registryConfiguration = registry;
registryConfigurationStub = sinon.stub(configRoot, 'registryConfiguration').value(registry);
});

afterEach(() => {
SystemJs.import.reset();
registryConfigurationStub.restore();
});

describe('preloadApp()', () => {
Expand Down
16 changes: 8 additions & 8 deletions ilc/client/ClientRouter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,15 @@ describe('client router', () => {
specialRoutes,
};

let router, configRoot, originalConfig;
let router, configRoot;

before(() => {
configRoot = getIlcConfigRoot();
originalConfig = configRoot.registryConfiguration;
configRoot.registryConfiguration = registryConfig;
sinon.stub(configRoot, 'registryConfiguration').value(registryConfig);
});

after(() => {
configRoot.registryConfiguration = originalConfig;
sinon.stub(configRoot, 'registryConfiguration').restore();
});

afterEach(() => {
Expand Down Expand Up @@ -684,7 +683,7 @@ describe('client router', () => {
const nonPrimaryKind = 'regular';
const appId = 'mounted_app__at__some_place';
const configRoot = getIlcConfigRoot();
configRoot.registryConfiguration = {
const registryConfiguration = {
...registryConfig,
apps: {
...registryConfig.apps,
Expand All @@ -693,6 +692,7 @@ describe('client router', () => {
},
},
};
sinon.stub(configRoot, 'registryConfiguration').value(registryConfiguration);

router = new ClientRouter(configRoot, {}, undefined, singleSpa, handlePageTransaction, undefined, logger);

Expand Down Expand Up @@ -814,7 +814,7 @@ describe('client router', () => {
};

const configRoot = getIlcConfigRoot();
configRoot.registryConfiguration = customRegistryConfig;
sinon.stub(configRoot, 'registryConfiguration').value(customRegistryConfig);

history.replaceState({}, undefined, '/');
router = new ClientRouter(configRoot, {}, undefined, singleSpa, handlePageTransaction, undefined, logger);
Expand Down Expand Up @@ -868,7 +868,7 @@ describe('client router', () => {
};

const configRoot = getIlcConfigRoot();
configRoot.registryConfiguration = customRegistryConfig;
sinon.stub(configRoot, 'registryConfiguration').value(customRegistryConfig);

history.replaceState({}, undefined, '/');
router = new ClientRouter(configRoot, {}, undefined, singleSpa, handlePageTransaction, undefined, logger);
Expand Down Expand Up @@ -928,7 +928,7 @@ describe('client router', () => {
};

const configRoot = getIlcConfigRoot();
configRoot.registryConfiguration = customRegistryConfig;
sinon.stub(configRoot, 'registryConfiguration').value(customRegistryConfig);

history.replaceState({}, undefined, '/');
router = new ClientRouter(configRoot, {}, undefined, singleSpa, handlePageTransaction, undefined, logger);
Expand Down
7 changes: 5 additions & 2 deletions ilc/client/composeAppSlotPairsToRegister.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import composeAppSlotPairsToRegister from './composeAppSlotPairsToRegister';
import { getIlcConfigRoot } from './configuration/getIlcConfigRoot';

describe('select slots to register', () => {
const configRoot = getIlcConfigRoot();
after(() => {
sinon.stub(configRoot, 'registryConfiguration').restore();
});
it('should select slots without any duplicated apps of slots from provided routes', () => {
const routes = [
{
Expand Down Expand Up @@ -107,10 +111,9 @@ describe('select slots to register', () => {
},
];

const configRoot = getIlcConfigRoot();
const registryConf = getRegistryMock().getConfig();
registryConf.routes = routes;
configRoot.registryConfiguration = registryConf;
sinon.stub(configRoot, 'registryConfiguration').value(registryConf);

const composedAppsJsonified = composeAppSlotPairsToRegister(configRoot).map((item) => item.toJSON());

Expand Down

0 comments on commit 3556cff

Please sign in to comment.