@muonic/muon 0.0.2-experimental-152-a931dc2.0 → 0.0.2-experimental-153-7d10f5f.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-experimental-152-a931dc2.0",
3
+ "version": "0.0.2-experimental-153-7d10f5f.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "web-test-runner \"./tests/**/*.test.js\" --coverage",
8
+ "test:scripts": "ava \"tests/scripts/utils/utils-test.js\"",
8
9
  "test:browserstack": "web-test-runner \"./tests/**/*.test.js\" --config web-test-runner.browserstack.config.mjs",
9
10
  "release": "standard-version"
10
11
  },
@@ -56,6 +57,7 @@
56
57
  "@web/test-runner": "0.14.0",
57
58
  "@web/test-runner-browserstack": "0.5.1",
58
59
  "@web/test-runner-playwright": "0.8.10",
60
+ "ava": "4.3.3",
59
61
  "sinon": "14.0.0"
60
62
  },
61
63
  "engines": {
@@ -4,7 +4,7 @@ import StorybookConfig from '../../storybook/server.config.mjs';
4
4
 
5
5
  const myServerDefinitions = [
6
6
  { name: 'no-open', type: Boolean },
7
- { name: 'no-watch', type: Boolean },
7
+ { name: 'no-watch', type: Boolean }
8
8
  ];
9
9
 
10
10
  const myConfig = commandLineArgs(myServerDefinitions, { partial: true });
@@ -139,7 +139,7 @@ const getAliasPaths = (type) => {
139
139
  obj[key] = [value];
140
140
  } else {
141
141
  // @TODO: This needs a better way to find the node_modules folder
142
- obj[key] = [`node_modules/${value}`];
142
+ obj[key] = [`${appRoot}/node_modules/${value}`];
143
143
  }
144
144
  });
145
145
 
@@ -177,7 +177,7 @@ const getAliasPaths = (type) => {
177
177
 
178
178
  const sourceFilesAnalyzer = async () => {
179
179
  const files = await findComponents();
180
- const paths = await getAliasPaths('glob');
180
+ const paths = getAliasPaths('glob');
181
181
  const options = {
182
182
  noEmitOnError: false,
183
183
  allowJs: true,
@@ -207,7 +207,8 @@ const sourceFilesAnalyzer = async () => {
207
207
  verbose: true,
208
208
  config: {
209
209
  format: 'json',
210
- discoverNodeModules: true
210
+ discoverNodeModules: true,
211
+ excludedDeclarationNames: ['ScopedElementsMixin']
211
212
  }
212
213
  }));
213
214
 
@@ -0,0 +1,9 @@
1
+ {
2
+ "components": {
3
+ "included": "inputter,card,image"
4
+ },
5
+ "tokens": {
6
+ "dir": ["tokens/*.json"],
7
+ "theme": "default"
8
+ }
9
+ }
@@ -0,0 +1,134 @@
1
+ const testRunner = require('ava');
2
+ const sinon = require('sinon');
3
+ const appRoot = require('app-root-path');
4
+
5
+ let utilsLibrary;
6
+ testRunner.before(async () => {
7
+ await import('../../../scripts/utils/index.mjs').then((utils) => {
8
+ utilsLibrary = utils;
9
+ });
10
+ });
11
+
12
+ testRunner('filterPathToCustomElements default', async (t) => {
13
+ const componentList = await utilsLibrary.filterPathToCustomElements('all');
14
+ t.is(componentList, '*');
15
+ });
16
+
17
+ testRunner('filterPathToCustomElements default array', async (t) => {
18
+ const componentList = await utilsLibrary.filterPathToCustomElements(['all']);
19
+ t.is(componentList, '*');
20
+ });
21
+
22
+ testRunner('filterPathToCustomElements single component', async (t) => {
23
+ const componentList = await utilsLibrary.filterPathToCustomElements('inputter');
24
+ t.is(componentList, 'inputter');
25
+ });
26
+
27
+ testRunner('filterPathToCustomElements single component in array', async (t) => {
28
+ const componentList = await utilsLibrary.filterPathToCustomElements(['inputter']);
29
+ t.is(componentList, 'inputter');
30
+ });
31
+
32
+ testRunner('filterPathToCustomElements multiple component', async (t) => {
33
+ const componentList = await utilsLibrary.filterPathToCustomElements(['inputter', 'image']);
34
+ t.is(componentList, '{inputter,image}');
35
+ });
36
+
37
+ testRunner('getConfig default file and root', async (t) => {
38
+ const config = utilsLibrary.getConfig();
39
+ t.true(config !== undefined);
40
+ });
41
+
42
+ testRunner('getConfig new file default root', async (t) => {
43
+ const config = utilsLibrary.getConfig('browserstack.json');
44
+ t.true(config !== undefined);
45
+ });
46
+
47
+ testRunner('getConfig config file not exist', async (t) => {
48
+ sinon.stub(process, 'exit');
49
+ utilsLibrary.getConfig('test.json');
50
+ t.true(process.exit.called);
51
+ t.true(process.exit.calledWith(1));
52
+ });
53
+
54
+ testRunner('getConfig config file', async (t) => {
55
+ const config = utilsLibrary.getConfig('tests/scripts/utils/test.json');
56
+ t.true(config !== undefined);
57
+ });
58
+
59
+ const componentsDefinitionMacro = async (t, expected) => {
60
+ const componentDefinition = await utilsLibrary.componentDefiner();
61
+ t.true(componentDefinition !== undefined);
62
+ t.true(componentDefinition.indexOf(`import '@webcomponents/scoped-custom-element-registry';`) > -1);
63
+ Object.keys(expected).forEach((component) => {
64
+ t.true(componentDefinition.indexOf(`import { ${expected[component]} } from '${process.cwd()}/components/${component}/src/${component}-component.js';`) > -1);
65
+ t.true(componentDefinition.indexOf(`customElements.define('muon-${component}', ${expected[component]});`) > -1);
66
+ });
67
+ };
68
+ componentsDefinitionMacro.title = (providedTitle, expected) => `${providedTitle} => ${Object.keys(expected)}`;
69
+
70
+ testRunner('componentDefiner', componentsDefinitionMacro, { card: 'Card', cta: 'Cta', detail: 'Detail', form: 'Form', icon: 'Icon', inputter: 'Inputter', image: 'Image' });
71
+
72
+ testRunner('getAliasPath glob', async (t) => {
73
+ const alias = utilsLibrary.getAliasPaths('glob');
74
+
75
+ t.deepEqual(alias, {
76
+ '@muon/components/*': [`${appRoot}/node_modules/@muonic/muon/components/*`],
77
+ '@muon/mixins/*': [`${appRoot}/node_modules/@muonic/muon/mixins/*`],
78
+ '@muon/directives/*': [`${appRoot}/node_modules/@muonic/muon/directives/*`],
79
+ '@muon/utils/*': [`${appRoot}/node_modules/@muonic/muon/utils/*`],
80
+ '@muon/tokens': [`${appRoot}/node_modules/@muonic/muon/build/tokens/es6/muon-tokens`]
81
+ });
82
+ });
83
+
84
+ testRunner('getAliasPath regex', async (t) => {
85
+ const alias = utilsLibrary.getAliasPaths('regex');
86
+ t.deepEqual(alias, [
87
+ {
88
+ find: /^@muon\/components\/(.*)$/,
89
+ replacement: '@muonic/muon/components/$1'
90
+ },
91
+ {
92
+ find: /^@muon\/mixins\/(.*)$/,
93
+ replacement: '@muonic/muon/mixins/$1'
94
+ },
95
+ {
96
+ find: /^@muon\/directives\/(.*)$/,
97
+ replacement: '@muonic/muon/directives/$1'
98
+ },
99
+ {
100
+ find: /^@muon\/utils\/(.*)$/,
101
+ replacement: '@muonic/muon/utils/$1'
102
+ },
103
+ {
104
+ find: /^@muon\/tokens$/,
105
+ replacement: '@muonic/muon/build/tokens/es6/muon-tokens'
106
+ }
107
+ ]);
108
+ });
109
+
110
+ testRunner('sourceFilesAnalyzer', async (t) => {
111
+ const result = await utilsLibrary.sourceFilesAnalyzer();
112
+ const jsonResult = JSON.parse(result);
113
+
114
+ const components = ['card', 'cta', 'detail', 'form', 'icon', 'image', 'inputter', 'inputter-detail'];
115
+ const propertiesMap = {
116
+ card: ['standardTemplate', 'image', 'alt', 'background', 'type'],
117
+ cta: ['href', 'standardTemplate', 'submitTemplate', 'resetTemplate', 'loading', 'loadingMessage', 'disabled', 'icon', 'type'],
118
+ detail: ['icon', 'standardTemplate', 'open', 'type'],
119
+ form: ['standardTemplate', 'type'],
120
+ icon: ['size', 'sizes', 'iconSize', 'standardTemplate', 'name', 'category', 'allSizes', 'url', 'describe', 'type'],
121
+ image: ['src', 'placeholderImage', 'standardTemplate', 'background', 'backgroundsize', 'alt', 'ratio', 'placeholder', 'loading', 'type'],
122
+ inputter: ['helper', 'slottedStyles', 'isHelperOpen', 'isPristine', 'isDirty', 'validity', 'validationMessage', 'validation', 'disableNative', 'showMessage', 'name', 'value', 'labelID', 'heading', 'mask', 'separator', 'type'],
123
+ 'inputter-detail': ['icon', 'standardTemplate', 'open', 'type']
124
+ };
125
+ t.deepEqual(jsonResult.tags?.map((tag) => tag.name), components);
126
+
127
+ components.forEach((component) => {
128
+ t.deepEqual(jsonResult.tags.filter((tag) => tag.name === component)[0].properties?.map(
129
+ (property) => property.name), propertiesMap[component]);
130
+ });
131
+ jsonResult.tags?.map((tag) => {
132
+ t.true(tag.description !== undefined, `${tag.name} description is not present`);
133
+ });
134
+ });