index int64 0 0 | repo_id stringlengths 16 181 | file_path stringlengths 28 270 | content stringlengths 1 11.6M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_index.scss | // Config
@import
'config';
// Vendors
@import
'~include-media';
// Functions
@import
'em',
'rem',
'im-to-em',
'logical',
'str-replace',
'easing',
'dash-join';
// Mixins
@import
'vendor-prefix',
'body-before',
'transform-origins',
'responsive-classes';
| 9,500 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_logical.scss | /**
* Give logical string for a "classic" placement
* @param {String} $placement - top/left/right/bottom/vertical/horizontal/t/r/b/l/v/h/x/y
* @return {String} - the logical prop fragment
*/
@function logical($placement) {
@if $placement == 'top' or $placement == 't' {
@return 'block-start';
}
@if $placement ... | 9,501 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_rem.scss | @use 'sass:math';
/**
* Calculate an rem value from a px value
* @param {Number} $px - A value to be converted in em
* @param {Number} $user-default-font-size - The default font-size of the browser. Should be equivalent to 16px
* @return {Number} - The $px value converted in rem
*/
@function rem($px, $user-defaul... | 9,502 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_responsive-classes.scss | @use 'sass:string';
@use 'sass:map';
$queries: (
default: 'all',
sm: '>xsmall',
md: '>small',
lg: '>medium',
xl: '>large',
);
/// Generate a class stack selector form a class list and responsive prefix
/// @param {List} $classnames - List of classes for generation
/// @param {String} $prefix - Prefix from $queri... | 9,503 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_str-replace.scss | /**
* Replace `$search` with `$replace` in `$string`
* @author Hugo Giraudel
* @param {String} $string - Initial string
* @param {String} $search - Substring to replace
* @param {String} $replace ('') - New value
* @return {String} - Updated string
*/
@function str-replace($string, $search, $replace: '') {
$ind... | 9,504 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_transform-origins.scss | /**
* Generate each transform origin possibilities
* @return {String} - CSS classes for each transform origin value
*/
@mixin transform-origins() {
@each $position,
$origin
in (
(top, bottom center),
(top-start, bottom left),
(top-end, bottom right),
(bottom, top center),
(bottom-start, top... | 9,505 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/lib/_vendor-prefix.scss | /**
* Generate vendor prefixes for a given property
* @param {String} $property - The given property from which generate vendor prefixes
* @param {String} $value - The value of the property
* @param {String} $prefixes - Wanted prefix•es
* @return {String} - The property with each prefix
*/
@mixin vendor-prefix($p... | 9,506 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/specifics/_list.scss | @use 'sass:math';
/*
* Items
* For conversations list
*/
.view-column-detail {
.scroll-inner {
@supports (overflow-y: overlay) {
overflow-y: overlay; // Deprecated, but didn't have the choice
}
}
}
.items-column-list {
inline-size: var(--width-conversation-column, calc(100vw * #{math.div($conversations-... | 9,507 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/specifics/_placeholder-loading.scss | /*
* Shared for placeholder loading
*/
@keyframes anime-loading-item {
from {
opacity: 0.05;
}
to {
opacity: 0.15;
}
}
%item-loading-pseudo {
content: '\00a0';
display: inline-block;
border-radius: var(--border-radius-sm);
background-color: currentcolor;
line-height: 1.2;
opacity: 0;
}
%appearing-con... | 9,508 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/specifics/_settings.scss | .settings-loading-page-title,
.settings-loading-section-title,
.settings-loading-paragraph-line {
&::before {
@extend %item-loading-pseudo;
@extend %placeholder-loading;
}
}
.settings-loading-page-title {
&::before {
inline-size: 30%;
}
}
.settings-loading-section-title {
&::before {
inline-size: 50%;
}... | 9,509 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/specifics/android-dark-mode.scss | /*
* Vars override
*/
:root {
--background-norm: #262a33;
--text-norm: white;
}
| 9,510 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/specifics/android-reset.scss | /*
* Specific reset for Android
*/
/* stylelint-disable-next-line value-keyword-case */
$font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue',
sans-serif;
article,
aside,
datalist,
details,
dialog,
figure,
footer,
header,
main,
menu,
nav,
section {
di... | 9,511 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_border.scss | .border {
border: 1px solid var(--border-norm);
}
@each $placement in (top, right, bottom, left) {
.border-#{$placement} {
#{dash-join('border', logical($placement))}: 1px solid var(--border-norm);
}
}
@each $color in (primary, norm, weak, danger, warning, success, info) {
// Initialize namespace
$prefix: '';
... | 9,512 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_colors.scss | @each $color in (primary, danger, warning, success, info) {
$prefix: if($color != 'primary', 'signal', '');
.bg-#{$color} {
background-color: var(--#{dash-join($prefix, $color)});
color: var(--#{dash-join($prefix, $color, 'contrast')});
a,
.link,
.button-link,
[class*='button-ghost'],
[class*='button-... | 9,513 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_cursors.scss | @each $cursor in (default, help, wait, grab, row-resize, col-resize, pointer, move, text, inherit) {
.cursor-#{$cursor} {
cursor: #{$cursor};
}
}
| 9,514 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_display.scss | @include responsive-classes(
(
block: (
display: block,
),
inline: (
display: inline,
),
inline-block: (
display: inline-block,
),
flex: (
display: flex,
flex-wrap: wrap,
),
inline-flex: (
display: inline-flex,
flex-wrap: wrap,
),
hidden: (
display: none,
),
table... | 9,515 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_divide.scss | .divide-x > * ~ * {
border-inline-start: 1px solid var(--border-norm);
}
.divide-y > * ~ * {
border-block-start: 1px solid var(--border-norm);
}
.divide-weak > * ~ * {
border-color: var(--border-weak);
}
| 9,516 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_flex.scss | @use 'sass:map';
.inline-flex-vcenter {
display: inline-flex;
flex-wrap: wrap;
}
.flex-flex-children,
.flex-no-min-children {
display: flex;
flex-wrap: wrap;
}
.flex-flex-children > * {
display: flex;
}
// ----------------------------------------------------------------------------
// Create an empty map to m... | 9,517 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_grid.scss | .grid-auto-fill {
display: grid;
inline-size: 100%;
grid-template-columns: repeat(auto-fill, minmax(var(--min-grid-template-column-size, #{rem(100)}), 1fr));
}
.grid-align-icon {
display: grid;
grid-template-columns: auto 1fr;
}
.grid-align-icon-center {
@extend .grid-align-icon;
align-items: center;
}
.grid... | 9,518 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_icons.scss | @use 'sass:math';
%icon {
display: inline-block;
vertical-align: middle;
fill: currentcolor;
}
@each $width in (6, 8, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 42, 48, 56, 60, 70, 100, 110) {
.icon-#{$width}p {
@extend %icon; // 🤔
inline-size: rem($width);
block-size: rem($width);
}
}
@each $wi... | 9,519 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_index.scss | /* stylelint-disable */
@import
'misc',
'icons',
'typo',
'colors',
'layout',
'display',
'position',
'sizing',
'spacing',
'flex',
'cursors',
'border',
'divide',
'outline',
'opacity',
'shadow',
'table',
'rounded',
'responsive',
'print',
'grid';
| 9,520 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_layout.scss | .mod,
.scroll-if-needed,
.overflow-auto {
overflow: auto;
}
.overflow-overlay {
overflow: auto; // fallback
overflow: overlay;
}
.scroll-horizontal-if-needed,
.overflow-x-auto {
overflow-x: auto;
}
.mod--hidden,
.no-scroll,
.overflow-hidden {
overflow: hidden;
}
.resize-none {
resize: none;
}
.float-left {
... | 9,521 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_misc.scss | .row--orderable {
z-index: $layer-modals;
/* In case the modal is open */
background: var(--background-norm);
color: var(--text-norm);
}
/*
* Welcome boxes in a 2 column design
* Make breakpoint overable
*/
$breakpoint-2-columns: 1180 !default;
@include media('<=#{em($breakpoint-2-columns, 16)}') {
.boxes-pl... | 9,522 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_opacity.scss | // When adding new opacity classes, add the values also in Storybook
// applications/storybook/src/stories/cssUtilities/Opacity.stories.tsx
.opacity-70 {
opacity: 0.7;
}
.opacity-65 {
opacity: 0.65;
}
.opacity-50 {
opacity: 0.5;
}
.opacity-40 {
opacity: 0.4;
}
.opacity-30 {
opacity: 0.3;
}
.opacity-0 {
opac... | 9,523 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_outline.scss | .outline-none {
// we remove outline for all cases, and add it back for focus-visible cases
&,
&--at-all {
&,
&:focus {
outline: 0;
}
}
&:focus-visible:not([tabindex='-1']) {
outline: 2px auto;
}
&--at-all {
&:focus-visible {
outline: 0;
}
}
}
| 9,524 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_position.scss | @include responsive-classes(
(
static: (
position: static,
),
relative: (
position: relative,
),
absolute: (
position: absolute,
z-index: 1,
),
fixed: (
position: fixed,
),
)
);
.absolute-center {
position: absolute;
inset-block-start: 50%;
inset-inline-start: 50%;
transform: tr... | 9,525 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_print.scss | @include media('print') {
/**
* add in this all elements which need to be hardly reseted for print
*/
body,
html,
.page,
.reset4print {
background-color: white;
background-image: none;
border: 0;
box-shadow: none;
color: black;
float: none;
block-size: auto;
margin: 0;
max-inline-size: 100%;
... | 9,526 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_responsive.scss | // For global structure adaptation in JS (page / skip links / header / main content / footer)
@include body-before('large-desktop', true);
.no-desktop {
display: none;
}
@include media('<=xlarge') {
@include body-before('medium-desktop');
}
@include media('<=large') {
@include body-before('small-desktop');
}
/**... | 9,527 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_rounded.scss | .rounded-sm {
border-radius: var(--border-radius-sm);
}
.rounded {
border-radius: var(--border-radius-md);
}
.rounded-lg {
border-radius: var(--border-radius-lg);
}
.rounded-xl {
border-radius: var(--border-radius-xl);
}
.rounded-full {
border-radius: var(--border-radius-full);
}
.rounded-50 {
border-radius:... | 9,528 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_shadow.scss | // .shadow-norm .shadow-lifted for purgecss
@each $type in (norm, lifted) {
:root {
--shadow-#{$type}: var(--shadow-#{$type}-offset)
rgb(var(--shadow-color, var(--shadow-default-color)) / var(--shadow-#{$type}-opacity));
}
}
@include responsive-classes(
(
shadow-norm: (
box-shadow: var(--shadow-norm-offs... | 9,529 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_sizing.scss | @use 'sass:math';
@use 'sass:map';
@function pixel-to-rem($value) {
@return if(type-of($value) == 'number' and unitless($value), rem($value), $value);
}
$dummy-map: ();
/// These sizings were defined in collaboration with the Design team.
/// Please contact the UXE team if you need any additional one.
/// If you ca... | 9,530 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_spacing.scss | @use 'sass:map';
// when updating margin sizes, please update them in Storybook accordingly
// applications/storybook/src/stories/cssUtilities/Margin.stories.tsx
@function pixel-to-rem($value) {
@return if(type-of($value) == 'number' and unitless($value), rem($value), $value);
}
$spacings: (
'0': 0,
'0\\\.5': 2,
... | 9,531 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_table.scss | .table-auto {
table-layout: auto;
}
.table-fixed {
table-layout: fixed;
}
| 9,532 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles/scss | petrpan-code/ProtonMail/WebClients/packages/styles/scss/utilities/_typo.scss | @use 'sass:map';
.text-monospace {
font-family: $font-family-monospace;
}
.text-tabular-nums {
font-variant: tabular-nums;
}
@if $use-other-typo-helpers==true {
$dummy-map: ();
@each $name, $size in (2xs: 9, xs: 10, sm: 12, rg: $base-font-size, lg: 16, xl: 18, 2xl: 20, 3xl: 22, 4xl: 24) {
$dummy-map: map.merge... | 9,533 |
0 | petrpan-code/ProtonMail/WebClients/packages/styles | petrpan-code/ProtonMail/WebClients/packages/styles/tasks/lint-svg.sh | #!/usr/bin/env bash
set -eo pipefail
for file in $(find . -type f -name "*.svg" -not -path "./node_modules/*"); do
echo "[LINT]: $file";
npx svgo "$file" -q 2>&1 -o /dev/null;
done;
| 9,534 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/testing/.eslintrc.js | module.exports = {
extends: ['@proton/eslint-config-proton'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
ignorePatterns: ['.eslintrc.js'],
};
| 9,535 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/testing/README.md | # Testing
The testing package contains common mocks and test data to use across the monorepo.
## Builders
Builders are using [test-data-bot](https://github.com/jackfranklin/test-data-bot) to generate data structures according to our types. It is reasonably flexible, allowing to create variations by using `traits` an... | 9,536 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/testing/index.ts | export { rest } from 'msw';
export * from './lib/api';
export * from './lib/builders';
export * from './lib/cache';
export * from './lib/context';
export * from './lib/event-manager';
export * from './lib/flush-promises';
export * from './lib/mockApiWithServer';
export * from './lib/mockModals';
export * from './lib/mo... | 9,537 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/testing/package.json | {
"name": "@proton/testing",
"description": "",
"license": "GPL-3.0",
"main": "index.ts",
"scripts": {
"check-types": "tsc",
"lint": "eslint index.ts lib --ext .js,.ts,.tsx --quiet --cache",
"pretty": "prettier --write $(find . -path ./node_modules -prune -o -type f -name '*.... | 9,538 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/testing/tsconfig.json | {
"extends": "../../tsconfig.base.json"
}
| 9,539 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/builders/address.ts | import { Address, AddressKey } from '@proton/shared/lib/interfaces';
export const buildAddress = (value?: Partial<Address>): Address => {
return {
CatchAll: false,
ID: 'YC-yr6jeFLCSwO5DuGBxGYMSHesNSgl3FcIZ-ITJtvTu2w6gBAmGnufX8Hnl0TK4P5p2VOPJ3kVcjHBSj9hQKw==',
DomainID: 'l8vWAXHBQmv0u7OVtPbc... | 9,540 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/builders/index.ts | export * from './user';
| 9,541 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/builders/user.ts | import { Key, UserModel } from '@proton/shared/lib/interfaces';
import { privateKeyA } from '../data';
export const buildUser = (value?: Partial<UserModel>): UserModel => {
return {
ID: 'rSUCW_Qlh8dCCsxWKPXvkUsoDNL5eW9FJUM7WX8jTPrDE3ftOMIfWt-BSuKaw5PZ7EQ6Zsp8HL9Y9qMv4Y5XJQ==',
Name: 'alice',
... | 9,542 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/data/index.ts | export * from './keys';
export * from './payments';
| 9,543 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/data/keys.ts | export const privateKeyA =
'-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: ProtonMail\n\nxcMGBF67AJkBCACdxh2Ix0gDdRQpnYbwiYgRMjv+D8dG8m2OpzNwC/N66XAV\naemfAJqKckkRIwq/+c/tbFbM8URQBJP7i+01LesCVC1BiH0DTQBVnrRN4B2B\nvkwziu6AHFHP/PkQICTA0hhpWr5f7XOcQ3QGumqc15fuK10QKqh+YBAF/QPH\nMBI2l/RPFSLKwRBF5vF1n+7URfSBnunKg3alTrd4... | 9,544 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/data | petrpan-code/ProtonMail/WebClients/packages/testing/data/payments/data-plans.ts | import { ADDON_NAMES, PLANS } from '@proton/shared/lib/constants';
import { PlansMap } from '@proton/shared/lib/interfaces';
export const PLANS_MAP: PlansMap = {
[PLANS.MAIL_PRO]: {
ID: 'BKiAUbkGnUPiy2c3b0sBCK557OBnWD7ACqqX3VPoZqOOyeMdupoWcjrPDBHy3ANfFKHnJs6qdQrdvHj7zjon_g==',
Type: 1,
Name... | 9,545 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/data | petrpan-code/ProtonMail/WebClients/packages/testing/data/payments/data-subscription.ts | import { CYCLE, PLANS, PLAN_TYPES } from '@proton/shared/lib/constants';
import { External, Renew, Subscription, SubscriptionModel } from '@proton/shared/lib/interfaces';
export const subscriptionMock: SubscriptionModel = {
ID: 'subscriptionId123',
InvoiceID: 'invoiceId123',
Cycle: CYCLE.YEARLY,
Period... | 9,546 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/data | petrpan-code/ProtonMail/WebClients/packages/testing/data/payments/index.ts | export * from './data-plans';
export * from './data-subscription';
| 9,547 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/api.ts | import noop from '@proton/utils/noop';
type HttpMethod = 'get' | 'post' | 'put' | 'delete';
type ApiMockHandler = (...arg: any[]) => any;
type ApiMockEntry = {
method?: HttpMethod;
handler: (...arg: any[]) => any;
};
type ApiMock = { [url: string]: ApiMockEntry[] | undefined };
export const apiMocksMap: Ap... | 9,548 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/builders.ts | import { build } from '@jackfranklin/test-data-bot';
import { CALENDAR_DISPLAY, CALENDAR_FLAGS, CALENDAR_TYPE } from '@proton/shared/lib/calendar/constants';
import { MEMBER_PERMISSIONS } from '@proton/shared/lib/calendar/permissions';
import { ADDRESS_TYPE } from '@proton/shared/lib/constants';
import { Address, Addr... | 9,549 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/cache.ts | import createCache from '@proton/shared/lib/helpers/cache';
import { STATUS } from '@proton/shared/lib/models/cache';
export interface ResolvedRequest<T> {
status: STATUS;
value: T;
}
export const resolvedRequest = <T>(value: T): ResolvedRequest<T> => ({ status: STATUS.RESOLVED, value });
export const mockCa... | 9,550 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/event-manager.ts | import { EventManager } from '@proton/shared/lib/eventManager/eventManager';
export const mockEventManager: EventManager = {
call: jest.fn().mockReturnValue(Promise.resolve()),
setEventID: jest.fn(),
getEventID: jest.fn(),
start: jest.fn(),
stop: jest.fn(),
reset: jest.fn(),
subscribe: jest... | 9,551 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/flush-promises.ts | const scheduler = typeof setImmediate === 'function' ? setImmediate : setTimeout;
export function flushPromises() {
return new Promise(function (resolve) {
scheduler(resolve);
});
}
| 9,552 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/handlers.ts | import { rest } from 'msw';
import { DEFAULT_MAILSETTINGS } from '@proton/shared/lib/mail/mailSettings';
import { addressBuilder, calendarBuilder, calendarEventBuilder, userBuilder } from './builders';
export const handlers = [
rest.get('/addresses', (req, res, ctx) => {
return res(
ctx.json(... | 9,553 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockApiWithServer.ts | import { jest } from '@jest/globals';
import fetch from 'cross-fetch';
function handleResponse(response: Response) {
return response.text().then((text) => {
const data = text && JSON.parse(text);
if (!response.ok) {
const error = (data && data.message) || response.statusText;
... | 9,554 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockMatchMedia.ts | Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn()... | 9,555 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockModals.ts | import { jest } from '@jest/globals';
import useModals from '@proton/components/hooks/useModals';
export const mockModals: ReturnType<typeof useModals> = {
createModal: jest.fn<any>(),
removeModal: jest.fn(),
hideModal: jest.fn(),
getModal: jest.fn<any>(),
modals: [],
};
| 9,556 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockNotifications.ts | import { jest } from '@jest/globals';
import useNotifications from '@proton/components/hooks/useNotifications';
export const mockNotifications: ReturnType<typeof useNotifications> = {
createNotification: jest.fn<any>(),
removeNotification: jest.fn(),
removeDuplicate: jest.fn(),
hideNotification: jest.... | 9,557 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockRandomValues.ts | type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array;
let original: undefined | typeof crypto.getRandomValues;
/**
* Mock crypto.getRandomValues using the mocked implementation (if given).... | 9,558 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockSpotlight.tsx | import { Children, MouseEventHandler, PropsWithChildren, ReactElement, useEffect } from 'react';
import { SpotlightProps } from '@proton/components/components';
/**
* Raw spotlight used as a mock for testing
*/
export const SpotlightMock = ({ children, show, content, onClose, onDisplayed }: PropsWithChildren<Spotli... | 9,559 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUnleash.ts | jest.mock('@protontech/proxy-client-react', () => ({
__esModule: true,
useFlag: jest.fn(),
useFlags: () => {},
useFlagsStatus: () => {},
}));
| 9,560 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseActiveBreakpoint.ts | import * as useActiveBreakpointModule from '@proton/components/hooks/useActiveBreakpoint';
export const mockUseActiveBreakpoint = (value?: Partial<ReturnType<typeof useActiveBreakpointModule.default>>) => {
const mockedUseActiveBreakpoint = jest.spyOn(useActiveBreakpointModule, 'default');
const values = {
... | 9,561 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseAddresses.ts | import * as useAddressesModule from '@proton/components/hooks/useAddresses';
import { Address } from '@proton/shared/lib/interfaces';
import { buildAddress } from '../builders/address';
export const mockUseAddresses = (value: [Address[]?, boolean?, any?] = []) => {
const [addresses, cached, miss = jest.fn()] = va... | 9,562 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseApi.ts | import * as useApiModule from '@proton/components/hooks/useApi';
export const mockUseApi = (value?: ReturnType<typeof useApiModule.default>) => {
const mockedUseApi = jest.spyOn(useApiModule, 'default');
mockedUseApi.mockReturnValue(value ?? jest.fn());
return mockedUseApi;
};
| 9,563 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseConfig.ts | import * as useConfigModule from '@proton/components/hooks/useConfig';
import { APPS, CLIENT_TYPES } from '@proton/shared/lib/constants';
export const mockUseConfig = (value?: Partial<ReturnType<typeof useConfigModule.default>>) => {
const mockedUseConfig = jest.spyOn(useConfigModule, 'default');
mockedUseCon... | 9,564 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseContactEmailsCache.ts | import * as useContactEmailsCacheModule from '@proton/components/containers/contacts/ContactEmailsProvider';
export const mockUseContactEmailsCache = (
value?: Partial<ReturnType<typeof useContactEmailsCacheModule.useContactEmailsCache>>
) => {
const mockedUseContactEmailsCache = jest.spyOn(useContactEmailsCac... | 9,565 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseEventManager.ts | import * as useEventManagerModule from '@proton/components/hooks/useEventManager';
export const mockUseEventManager = (value?: Partial<ReturnType<typeof useEventManagerModule.default>>) => {
const mockedUseEventManager = jest.spyOn(useEventManagerModule, 'default');
mockedUseEventManager.mockReturnValue({
... | 9,566 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseFeature.ts | import * as useFeatureModule from '@proton/components/hooks/useFeature';
import { DeepPartial } from '@proton/shared/lib/interfaces';
type HookReturnType = ReturnType<typeof useFeatureModule.default>;
/**
* Basic and raw useFeature mock
*
* Example:
* ```
* const mockedUseFeature = mockUseFeature({ feature: { Va... | 9,567 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseFlag.ts | import * as useFlagModule from '@protontech/proxy-client-react';
export const mockUseFlag = (value: boolean = false) => {
const mockedUseFlag = jest.spyOn(useFlagModule, 'useFlag');
mockedUseFlag.mockReturnValue(value);
return mockedUseFlag;
};
| 9,568 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseFolders.ts | import * as useFoldersModule from '@proton/components/hooks/useCategories';
import { Folder } from '@proton/shared/lib/interfaces/Folder';
export const mockUseFolders = (params?: [Folder[]?, boolean?]) => {
const [value = [], loading = false] = params ?? [];
const mockedUseFolders = jest.spyOn(useFoldersModul... | 9,569 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseHistory.ts | import * as reactRouterDomModule from 'react-router-dom';
// A simple workaround for jest issue not solved yet
// https://stackoverflow.com/questions/67872622/jest-spyon-not-working-on-index-file-cannot-redefine-property
jest.mock('react-router-dom', () => {
return {
__esModule: true,
...jest.requi... | 9,570 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseLabels.ts | import * as useLabelsModule from '@proton/components/hooks/useCategories';
import { Label } from '@proton/shared/lib/interfaces/Label';
export const mockUseLabels = (params?: [Label[]?, boolean?]) => {
const [value = [], loading = false] = params ?? [];
const mockedUseLabels = jest.spyOn(useLabelsModule, 'use... | 9,571 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseLocation.ts | import * as reactRouterDomModule from 'react-router-dom';
// A simple workaround for jest issue not solved yet
// https://stackoverflow.com/questions/67872622/jest-spyon-not-working-on-index-file-cannot-redefine-property
jest.mock('react-router-dom', () => {
return {
__esModule: true,
...jest.requi... | 9,572 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseMailSettings.ts | import * as useMailSettingsModule from '@proton/components/hooks/useMailSettings';
import { MIME_TYPES } from '@proton/shared/lib/constants';
import { MailSettings } from '@proton/shared/lib/interfaces';
import { DEFAULT_MAILSETTINGS } from '@proton/shared/lib/mail/mailSettings';
const defaultMailSettings: MailSetting... | 9,573 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseNotifications.ts | import * as useNotificationsModule from '@proton/components/hooks/useNotifications';
export const mockUseNotifications = (value?: Partial<ReturnType<typeof useNotificationsModule.default>>) => {
const mockedUseNotifications = jest.spyOn(useNotificationsModule, 'default');
mockedUseNotifications.mockReturnValu... | 9,574 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseSelector.ts | import * as useSelectorModule from 'react-redux';
// A simple workaround for jest issue not solved yet
// https://stackoverflow.com/questions/67872622/jest-spyon-not-working-on-index-file-cannot-redefine-property
jest.mock('react-redux', () => {
return {
__esModule: true,
...jest.requireActual('rea... | 9,575 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseSpotlightOnFeature.ts | import * as useSpotlightOnFeatureModule from '@proton/components/hooks/useSpotlightOnFeature';
type HookReturnType = ReturnType<typeof useSpotlightOnFeatureModule.default>;
export const mockUseSpotlightOnFeature = (values: Partial<HookReturnType>) => {
const mockedUseSpotlightOnFeature = jest.spyOn(useSpotlightOnF... | 9,576 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseUser.ts | import * as useUserModule from '@proton/components/hooks/useUser';
import { UserModel } from '@proton/shared/lib/interfaces';
import { buildUser } from '../builders';
export const mockUseUser = (value: [Partial<UserModel>?, boolean?, any?] = []) => {
const [user, cached, miss = jest.fn()] = value;
const mocke... | 9,577 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/mockUseWelcomeFlags.ts | import * as useWelcomeFlagsModule from '@proton/components/hooks/useWelcomeFlags';
export const mockUseWelcomeFlags = ([state, setDone]: [
Partial<useWelcomeFlagsModule.WelcomeFlagsState>?,
(() => void)?
] = []) => {
const mockedUseWelcomeFlags = jest.spyOn(useWelcomeFlagsModule, 'default');
mockedUseW... | 9,578 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing | petrpan-code/ProtonMail/WebClients/packages/testing/lib/server.ts | import { setupServer } from 'msw/node';
import { handlers } from './handlers';
export const server = setupServer(...handlers);
| 9,579 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/context/hocs.ts | import React, { ComponentType } from 'react';
import { WrapperComponent } from '@testing-library/react-hooks';
interface HOC<T> {
(Component: ComponentType<T>): ComponentType<T>;
}
const reduceHOCs = <T>(hocs: HOC<T>[]): HOC<T> => hocs.reduce((reduced, next) => (c) => next(reduced(c)));
/**
* A helper function... | 9,580 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/context/index.ts | export * from './hocs';
export * from './providers';
| 9,581 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/context/providers.tsx | import { ComponentType } from 'react';
import ApiContext from '@proton/components/containers/api/apiContext';
import AuthenticationProvider, {
Props as AuthenticationProviderProps,
} from '@proton/components/containers/authentication/Provider';
import { CacheProvider } from '@proton/components/containers/cache';
i... | 9,582 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/payments/api-endpoints.ts | import {
Autopay,
PAYMENT_METHOD_TYPES,
PAYMENT_TOKEN_STATUS,
PayPalDetails,
PaymentMethodStatus,
SavedCardDetails,
SavedPaymentMethod,
} from '@proton/components/payments/core';
import { createToken, queryPaymentMethodStatus, queryPaymentMethods } from '@proton/shared/lib/api/payments';
imp... | 9,583 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/payments/index.ts | export * from './mockVerifyPayment';
export * from './api-endpoints';
| 9,584 |
0 | petrpan-code/ProtonMail/WebClients/packages/testing/lib | petrpan-code/ProtonMail/WebClients/packages/testing/lib/payments/mockVerifyPayment.ts | import { PAYMENT_METHOD_TYPES, TokenPaymentMethod } from '@proton/components/payments/core';
export function mockVerifyPayment() {
const verifyPayment = jest.fn();
(verifyPayment as any).mockVerification = (
value: TokenPaymentMethod = {
Payment: {
Type: PAYMENT_METHOD_TYPE... | 9,585 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/.eslintrc.js | module.exports = {
extends: ['@proton/eslint-config-proton'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
ignorePatterns: ['.eslintrc.js'],
};
| 9,586 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/README.md | # Util
Generic business-agnostic utils. Inspired by parallels such as lodash or ramda.
1 concern (usually 1 function) per file. Necessarily pure.
| 9,587 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/addItem.test.ts | import addItem from './addItem';
describe('addItem()', () => {
it('adds item to empty array', () => {
const item = 'item to add';
const result = addItem([], item);
expect(result).toStrictEqual([item]);
});
it('appends item to ends of array', () => {
const array = ['item 1... | 9,588 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/addItem.ts | /**
* Adds an item to an array
*/
export default function addItem<T>(array: T[], item: T) {
return array.concat(item);
}
| 9,589 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/arraysContainSameElements.test.ts | import arraysContainSameElements from './arraysContainSameElements';
describe('arraysContainSameElements()', () => {
it('returns true for empty arrays', () => {
const result = arraysContainSameElements([], []);
expect(result).toBeTruthy();
});
it('returns false if arrays are of different ... | 9,590 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/arraysContainSameElements.ts | export default function arraysContainSameElements<T>(array1: T[], array2: T[]) {
if (array1.length !== array2.length) {
return false;
}
return array1.every((element) => array2.includes(element));
}
| 9,591 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/capitalize.test.ts | import capitalize from './capitalize';
describe('capitalize()', () => {
it('returns undefined when called with undefined', () => {
expect(capitalize(undefined)).toBe(undefined);
});
it('returns an empty string when an empty string is provided', () => {
expect(capitalize('')).toBe('');
... | 9,592 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/capitalize.ts | /**
* Capitalize the first letter in a string.
*/
export default function capitalize(str: string | undefined) {
if (str === undefined) {
return;
}
if (str === '') {
return str;
}
return str[0].toUpperCase() + str.slice(1);
}
| 9,593 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/chunk.test.ts | import chunk from './chunk';
describe('chunk()', () => {
it('creates an array of chunks of a given other array of fixed size', () => {
const output = chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], 3);
const expected = [
['a', 'b', 'c'],
['d', 'e', 'f'],
['... | 9,594 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/chunk.ts | /**
* Divide an array into sub-arrays of a fixed chunk size
*/
const chunk = <T>(list: T[] = [], size = 1) => {
return list.reduce<T[][]>((res, item, index) => {
if (index % size === 0) {
res.push([]);
}
res[res.length - 1].push(item);
return res;
}, []);
};
export... | 9,595 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/clamp.test.ts | import clamp from './clamp';
describe('clamp()', () => {
it('returns the exact value passed in if it already lies between min & max', () => {
expect(clamp(7, 0, 10)).toBe(7);
});
it('returns the min if the value passed in is lower than min', () => {
expect(clamp(-2, 0, 10)).toBe(0);
})... | 9,596 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/clamp.ts | /**
* Makes sure a value can't leave the bounds of defined
* min & max values. If n is larger than max or smaller
* than min, returns min or max respectively.
*/
const clamp = (value: number, min: number, max: number) => Math.min(Math.max(min, value), max);
export default clamp;
| 9,597 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/clsx.test.ts | import clsx from './clsx';
describe('clsx()', () => {
it('handles array arguments', () => {
const result = clsx(['a', 'b']);
expect(result).toBe('a b');
});
it('returns empty string when empty array is passed', () => {
const result = clsx([]);
expect(result).toBe('');
... | 9,598 |
0 | petrpan-code/ProtonMail/WebClients/packages | petrpan-code/ProtonMail/WebClients/packages/utils/clsx.ts | type V = string | boolean | null | undefined;
function clsx(args: V[]): string;
function clsx(...args: V[]): string;
function clsx(...args: any): any {
return args
.flat()
.filter((a: any) => typeof a === 'string')
.map((a: string) => a.trim())
.filter((a: string) => a !== '')
... | 9,599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.