@reown/appkit-scaffold-ui
Version:
The full stack toolkit to build onchain app UX.
112 lines • 4.66 kB
JavaScript
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { OptionsController } from '@reown/appkit-controllers';
import { W3mLegalFooter } from '../../src/partials/w3m-legal-footer';
describe('W3mLegalFooter', () => {
let element;
beforeEach(() => {
element = document.createElement('w3m-legal-footer');
document.body.appendChild(element);
});
afterEach(() => {
document.body.removeChild(element);
});
it('renders branding when legalCheckbox is enabled and URLs are set', async () => {
const originalState = { ...OptionsController.state };
try {
OptionsController.state = {
...OptionsController.state,
termsConditionsUrl: 'https://example.com/terms',
privacyPolicyUrl: 'https://example.com/privacy',
features: {
...OptionsController.state.features,
legalCheckbox: true
}
};
await element.updateComplete;
const flexElement = element.shadowRoot?.querySelector('wui-flex');
expect(flexElement).toBeDefined();
const brandingElement = flexElement?.querySelector('wui-ux-by-reown');
expect(brandingElement).toBeDefined();
}
finally {
OptionsController.state = originalState;
}
});
it('renders branding when no URLs are set', async () => {
const originalState = { ...OptionsController.state };
try {
OptionsController.state = {
...OptionsController.state,
termsConditionsUrl: '',
privacyPolicyUrl: '',
features: {
...OptionsController.state.features,
legalCheckbox: false
}
};
await element.updateComplete;
const flexElement = element.shadowRoot?.querySelector('wui-flex');
expect(flexElement).toBeDefined();
const brandingElement = flexElement?.querySelector('wui-ux-by-reown');
expect(brandingElement).toBeDefined();
}
finally {
OptionsController.state = originalState;
}
});
it('renders legal text and branding when URLs are set and legalCheckbox is disabled', async () => {
const originalState = { ...OptionsController.state };
try {
OptionsController.state = {
...OptionsController.state,
termsConditionsUrl: 'https://example.com/terms',
privacyPolicyUrl: 'https://example.com/privacy',
features: {
...OptionsController.state.features,
legalCheckbox: false
}
};
await element.updateComplete;
const flexElement = element.shadowRoot?.querySelector('wui-flex');
expect(flexElement).toBeDefined();
const textElement = flexElement?.querySelector('wui-text');
expect(textElement).toBeDefined();
const brandingElement = flexElement?.querySelector('wui-ux-by-reown');
expect(brandingElement).toBeDefined();
}
finally {
OptionsController.state = originalState;
}
});
it('does not render branding when remoteFeatures.reownBranding is false', async () => {
const originalState = { ...OptionsController.state };
const originalRemoteFeatures = { ...OptionsController.state.remoteFeatures };
try {
OptionsController.state = {
...OptionsController.state,
termsConditionsUrl: 'https://example.com/terms',
privacyPolicyUrl: 'https://example.com/privacy',
features: {
...OptionsController.state.features,
legalCheckbox: false
},
remoteFeatures: {
...OptionsController.state.remoteFeatures,
reownBranding: false
}
};
await element.updateComplete;
const flexElement = element.shadowRoot?.querySelector('wui-flex');
expect(flexElement).toBeDefined();
const brandingElement = flexElement?.querySelector('wui-ux-by-reown');
expect(brandingElement).toBeNull();
}
finally {
OptionsController.state = {
...originalState,
remoteFeatures: originalRemoteFeatures
};
}
});
});
//# sourceMappingURL=w3m-legal-footer.test.js.map