Skip to content

Commit 834d886

Browse files
committed
!refactor: rename load to loadSystem
1 parent 0836978 commit 834d886

15 files changed

+69
-71
lines changed
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {createElement as h} from 'react';
22

3-
import {load} from '../../../../index.js';
3+
import {loadSystem} from '../../../../index.js';
44
import {useConfig} from '../../../../lib/system/hooks.js';
55
import defaultConfig from '../../../fixtures/default-config.js';
66
import config from '../../../fixtures/test-config.js';
@@ -11,12 +11,12 @@ describe('useConfig', () => {
1111
});
1212

1313
it('should return the default config for a default system', () => {
14-
load({h});
14+
loadSystem({h});
1515
expect(useConfig()).deep.equal(defaultConfig);
1616
});
1717

1818
it('should return the provided config', () => {
19-
load({h, config});
19+
loadSystem({h, config});
2020
expect(useConfig()).deep.equal(config);
2121
});
2222
});

cypress/tests/system/hooks/use-css.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {mount} from '@cypress/react';
22
import React, {createElement as h} from 'react';
33

4-
import {load} from '../../../../index.js';
4+
import {loadSystem} from '../../../../index.js';
55
import {useCss} from '../../../../lib/system/hooks.js';
66
import system from '../../../fixtures/test-system.js';
77

@@ -30,7 +30,7 @@ describe('useCss', () => {
3030
});
3131

3232
it('should retrieve a css function that can be used to apply and compose styles', () => {
33-
load({h, system});
33+
loadSystem({h, system});
3434
mount(
3535
<CustomElement
3636
id="test"

cypress/tests/system/hooks/use-h.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {createElement as h} from 'react';
22

3-
import {load} from '../../../../index.js';
3+
import {loadSystem} from '../../../../index.js';
44
import {useH} from '../../../../lib/system/hooks.js';
55

66
describe('useH', () => {
@@ -9,7 +9,7 @@ describe('useH', () => {
99
});
1010

1111
it('should retrieve the provided h (React.createElement) function', () => {
12-
load({h});
12+
loadSystem({h});
1313
expect(useH()).equal(h);
1414
});
1515
});

cypress/tests/system/hooks/use-icon.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {mount} from '@cypress/react';
22
import React, {createElement as h} from 'react';
33
import {renderToStaticMarkup} from 'react-dom/server.js';
44

5-
import {load, useIcon} from '../../../../index.js';
5+
import {loadSystem, useIcon} from '../../../../index.js';
66
import {parseSvgElement} from '../../../../lib/util/parse-svg-element.js';
77
import system from '../../../fixtures/test-system.js';
88

@@ -18,15 +18,15 @@ describe('useIcon', () => {
1818
});
1919

2020
it('should return null if icon is not found in the system', () => {
21-
load({h, system});
21+
loadSystem({h, system});
2222
mount(<CustomElement icon="invalid icon" />);
2323

2424
cy.get('@iconSvg').should('equal', null);
2525
});
2626

2727
it('should return an SVG element for the specified icon from the system', () => {
2828
const icon = 'x';
29-
load({h, system});
29+
loadSystem({h, system});
3030
mount(<CustomElement icon={icon} />);
3131

3232
const svg = system.icons[icon];
@@ -39,7 +39,7 @@ describe('useIcon', () => {
3939
});
4040

4141
it('should return an SVG element for the specified nested icon from the system', () => {
42-
load({h, system});
42+
loadSystem({h, system});
4343
mount(<CustomElement icon="nested.x" />);
4444
const svg = system.icons.nested.x;
4545
const svgElement = parseSvgElement({h, svg});
@@ -51,7 +51,7 @@ describe('useIcon', () => {
5151
});
5252

5353
it('should return an SVG element for the specified direct icon from the system', () => {
54-
load({h, system});
54+
loadSystem({h, system});
5555
mount(<CustomElement icon="a.b.c" />);
5656
const svg = system.icons['a.b.c'];
5757
const svgElement = parseSvgElement({h, svg});

cypress/tests/system/hooks/use-styles.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {mount} from '@cypress/react';
22
import React, {createElement as h} from 'react';
33

4-
import {load, useStyles} from '../../../../index.js';
4+
import {loadSystem, useStyles} from '../../../../index.js';
55
import system from '../../../fixtures/test-system.js';
66

77
function CustomElement() {
@@ -16,7 +16,7 @@ describe('useStyles', () => {
1616
});
1717

1818
it('should return styles from the system', () => {
19-
load({h, system});
19+
loadSystem({h, system});
2020
mount(<CustomElement />);
2121

2222
cy.get('@styles').should('deep.equal', system.styles);

cypress/tests/system/hooks/use-system.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {mount} from '@cypress/react';
22
import React, {createElement as h} from 'react';
33

4-
import {createSystem, load, useSystem} from '../../../../index.js';
4+
import {createSystem, loadSystem, useSystem} from '../../../../index.js';
55
import system from '../../../fixtures/test-system.js';
66

77
function CustomElement() {
@@ -16,7 +16,7 @@ describe('useSystem', () => {
1616
});
1717

1818
it('should retrieve the entire system', () => {
19-
load({h, system});
19+
loadSystem({h, system});
2020
mount(<CustomElement />);
2121

2222
cy.get('@system').should('deep.equal', createSystem(system));

cypress/tests/system/hooks/use-variant.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {mount} from '@cypress/react';
22
import React, {createElement as h} from 'react';
33

4-
import {load, useVariant} from '../../../../index.js';
4+
import {loadSystem, useVariant} from '../../../../index.js';
55
import system from '../../../fixtures/test-system.js';
66

77
function CustomElement({variant}) {
@@ -16,14 +16,14 @@ describe('useVariant', () => {
1616
});
1717

1818
it('should return undefined if variant style is not found in the system', () => {
19-
load({h, system});
19+
loadSystem({h, system});
2020
mount(<CustomElement variant="invalid.variant" />);
2121

2222
cy.get('@variantStyle').should('equal', undefined);
2323
});
2424

2525
it('should return the variant style from the system', () => {
26-
load({h, system});
26+
loadSystem({h, system});
2727
mount(<CustomElement variant="Button.primary" />);
2828

2929
cy.get('@variantStyle').should(

cypress/tests/system/load/h/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {Element, Icon, Layout, Text, load} from '../../../../../index.js';
1+
import {Element, Icon, Layout, Text, loadSystem} from '../../../../../index.js';
22
import system from '../../../../fixtures/test-system.js';
33

44
export {assert, createCustomElement};
55

66
const createCustomElement = (h) => {
7-
load({h, system});
7+
loadSystem({h, system});
88

99
const CustomElement = ({x, ...rest}) =>
1010
h('blockquote', rest, `Custom Element: ${x}`);

cypress/tests/system/load/load.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {mount} from '@cypress/react';
22
import React, {createElement as h} from 'react';
33

4-
import {createSystem, load, useSystem} from '../../../../index.js';
4+
import {createSystem, loadSystem, useSystem} from '../../../../index.js';
55
import system from '../../../fixtures/test-system.js';
66

77
function CustomElement() {
@@ -10,21 +10,21 @@ function CustomElement() {
1010
return <pre>{JSON.stringify(system, null, 2)}</pre>;
1111
}
1212

13-
describe('load', () => {
13+
describe('loadSystem', () => {
1414
// Skipping because of : https://github.com/cypress-io/cypress/issues/16635
1515
it.skip('should throw if system is not loaded when using system components', () => {
1616
expect(() => mount(<CustomElement />)).to.throw();
1717
});
1818

1919
it('should load the default system if no system is provided', () => {
20-
load({h});
20+
loadSystem({h});
2121
mount(<CustomElement />);
2222

2323
cy.get('@system').should('deep.equal', createSystem());
2424
});
2525

2626
it('should load the provided system', () => {
27-
load({h, system});
27+
loadSystem({h, system});
2828
mount(<CustomElement />);
2929

3030
cy.get('@system').should('deep.equal', createSystem(system));

cypress/utils/mount-with-system.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {mount as cypressMount} from '@cypress/react';
22
import {createElement as h} from 'react';
33
import themeSpec from 'uinix-theme-spec';
44

5-
import {load, merge} from '../../index.js';
5+
import {loadSystem, merge} from '../../index.js';
66

77
export {mountWithSystem};
88

@@ -11,6 +11,6 @@ const defaultSystem = {
1111
};
1212

1313
const mountWithSystem = (element, system = defaultSystem, config = {}) => {
14-
load({h, config, system: merge(defaultSystem)(system)});
14+
loadSystem({h, config, system: merge(defaultSystem)(system)});
1515
cypressMount(element);
1616
};

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export {
1212
useTheme,
1313
useVariant,
1414
} from './lib/system/hooks.js';
15-
export {load} from './lib/system/load.js';
16-
export {createSystem} from './lib/system/create.js';
15+
export {loadSystem} from './lib/system/load-system.js';
16+
export {createSystem} from './lib/system/create-system.js';
1717

1818
// Utils
1919
export {merge} from 'uinix-fp';
File renamed without changes.

lib/system/hooks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {props} from 'uinix-fp';
22

33
import {parseSvgElement} from '../util/parse-svg-element.js';
4-
import {getStore} from './load.js';
4+
import {getStore} from './load-system.js';
55

66
export {
77
useConfig,

lib/system/load.js renamed to lib/system/load-system.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import {merge} from 'uinix-fp';
22
import {combineStyles, createThemeRenderer} from 'uinix-theme';
33

4-
import {createSystem} from './create.js';
5-
6-
export {load, getStore};
4+
import {createSystem} from './create-system.js';
75

86
let store;
97

10-
const getStore = () => store;
8+
export const getStore = () => store;
119

1210
const defaultConfig = {
1311
elementShorthandPropsMapping: {},
@@ -19,7 +17,7 @@ const defaultConfig = {
1917
responsiveCssProperties: [],
2018
};
2119

22-
const load = ({
20+
export const loadSystem = ({
2321
config: initialConfig = defaultConfig,
2422
h,
2523
system: initialSystem,

0 commit comments

Comments
 (0)