Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Pircher <[email protected]>
  • Loading branch information
patricklx committed Jul 8, 2024
1 parent 9166148 commit 79eb943
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 119 deletions.
1 change: 0 additions & 1 deletion carbon-components-ember/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
"ember-power-select": "^8.2.0",
"ember-ref-modifier": "^1.0.0",
"ember-resize-modifier": "^0.6.0",
"ember-simple-mu-resolver": "^0.1.11",
"ember-template-imports": "^3.4.2",
"ember-template-lint-plugin-prettier": "^4.2.0",
"ember-tooltips": "^3.6.0",
Expand Down
33 changes: 5 additions & 28 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 52 additions & 50 deletions test-app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,56 @@
module.exports = {
overrides: [
// node files
{
files: [
'.ember-cli.js',
'.eslintrc.js',
'.prettierrc.js',
'.stylelintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'babel.config.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'lib/*/index.js',
'server/**/*.js'
],
excludedFiles: [
'app/**',
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true
},
plugins: ['n'],
rules: Object.assign({}, require('eslint-plugin-n').configs.recommended.rules, {
// add your custom rules and overrides for node files here
'use strict';

// this can be removed once the following is fixed
// https://github.com/mysticatea/eslint-plugin-node/issues/77
'node/no-unpublished-require': 'off'
}),
extends: [
'plugin:node/recommended'
],
module.exports = {
root: true,
parser: 'ember-eslint-parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
babelOptions: {
root: __dirname,
},
},
plugins: ['ember'],
extends: ['plugin:ember/recommended', 'plugin:prettier/recommended'],
globals: {
WithRequired: true,
},
env: {
browser: true,
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['**/*.{js,ts}'],
plugins: ['ember'],
files: ['**/*.ts'],
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:ember/recommended', // or other configuration
'plugin:@typescript-eslint/recommended',
'plugin:ember/recommended',
],
rules: {
// override / enable optional rules
'ember/no-replace-test-comments': 'error'
}
'ember/no-at-ember-render-modifiers': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'ember/no-empty-glimmer-component-classes': 'off',
},
},
{
files: ['**/*.gts'],
parser: 'ember-eslint-parser',
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:ember/recommended',
'plugin:ember/recommended-gts',
],
rules: {
'ember/no-at-ember-render-modifiers': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'ember/no-empty-glimmer-component-classes': 'off',
},
},
{
files: ['**/*.gjs'],
Expand All @@ -72,12 +62,24 @@ module.exports = {
'plugin:ember/recommended-gjs',
],
},
// node files
{
files: ['tests/**/*.{js,ts,gjs,gts}'],
rules: {
// override / enable optional rules
'ember/no-replace-test-comments': 'error'
}
files: [
'./.eslintrc.cjs',
'./.prettierrc.cjs',
'./.template-lintrc.cjs',
'./addon-main.cjs',
'./babel.config.js',
],
parserOptions: {
sourceType: 'script',
},
env: {
browser: false,
node: true,
},
plugins: ['n'],
extends: ['plugin:n/recommended'],
},
],
};
10 changes: 2 additions & 8 deletions test-app/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
'use strict';

module.exports = {
overrides: [
{
files: '*.{js,ts}',
options: {
singleQuote: true,
},
},
],
plugins: ['prettier-plugin-ember-template-tag'],
singleQuote: true,
};
12 changes: 6 additions & 6 deletions test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"",
"build:ember": "EMBROIDER_PREBUILD=true ember b",
"test:ember": "node ./scripts/run-tests.mjs",
"test:ember:serve": "vite --open tests/"
"ember:serve": "vite --open tests/"
},
"devDependencies": {
"@babel/eslint-parser": "^7.22.5",
Expand Down Expand Up @@ -64,7 +64,6 @@
"ember-page-title": "^7.0.0",
"ember-qunit": "^8.1.0",
"ember-resolver": "^10.1.1",
"ember-routable-component": "^0.2.0",
"ember-source": "^5.9.0",
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^5.11.0",
Expand All @@ -78,17 +77,18 @@
"eslint-plugin-qunit": "^8.0.0",
"js-reporters": "^2.1.0",
"loader.js": "^4.7.0",
"prettier": "^3.2.5",
"prettier-plugin-ember-template-tag": "^2.0.1",
"prettier": "^3.3.2",
"prettier-plugin-ember-template-tag": "^2.0.2",
"puppeteer-chromium-resolver": "^22.0.0",
"qunit": "^2.19.4",
"qunit-dom": "^2.0.0",
"stylelint": "^15.9.0",
"stylelint-config-standard": "^33.0.0",
"stylelint-prettier": "^3.0.0",
"tracked-built-ins": "^3.1.1",
"vite": "^5.3.1",
"webpack": "^5.90.3"
"webpack": "^5.90.3",
"vite": "^5.1.6",
"ember-routable-component": "^1.1.0"
},
"engines": {
"node": "16.* || >= 18"
Expand Down
18 changes: 11 additions & 7 deletions test-app/tests/components/breadcrumbs-test.gts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ import { render, click } from '@ember/test-helpers';
import Breadcrumbs from 'carbon-components-ember/components/breadcrumbs';
import { array } from '@ember/helper';


module('Integration | Component | Breadcrumbs', (hooks) => {
setupRenderingTest(hooks);

test('should display items', async function(assert) {
await render(<template><Breadcrumbs @crumbs={{array "a" "b" "c"}}></Breadcrumbs></template>);
test('should display items', async function (assert) {
await render(
<template><Breadcrumbs @crumbs={{array 'a' 'b' 'c'}} /></template>,
);

assert.dom('.cds--breadcrumb-item').exists({ count: 3 }, 'should display all items');
assert
.dom('.cds--breadcrumb-item')
.exists({ count: 3 }, 'should display all items');
});

test('should allow click without handler', async function(assert) {
test('should allow click without handler', async function (assert) {
assert.expect(0);
await render(<template><Breadcrumbs @crumbs={{array "a" "b" "c"}}></Breadcrumbs></template>);
await render(
<template><Breadcrumbs @crumbs={{array 'a' 'b' 'c'}} /></template>,
);

await click('.cds--breadcrumb-item');
});
});

52 changes: 33 additions & 19 deletions test-app/tests/components/button-test.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ import { setupRenderingTest } from 'ember-qunit';
import { render, click, rerender, settled } from '@ember/test-helpers';
import Button from 'carbon-components-ember/components/button';


module('Integration | Component | Button', (hooks) => {
setupRenderingTest(hooks);

test('should set as primary', async function(assert) {
await render(<template><Button @type="primary"></Button></template>);
await rerender()
test('should set as primary', async function (assert) {
await render(<template><Button @type='primary' /></template>);
await rerender();

assert.dom('button').hasClass('cds--btn--primary');
});

test('should set as secondary', async function(assert) {
await render(<template><Button @type="secondary"></Button></template>);
test('should set as secondary', async function (assert) {
await render(<template><Button @type='secondary' /></template>);
assert.dom('button').hasClass('cds--btn--secondary');
});

test('should show loading indicator for async click handler', async function(assert) {

test('should show loading indicator for async click handler', async function (assert) {
let promise;
const onClick = function() {
promise = new Promise(res => setTimeout(res, 100));
const onClick = function () {
promise = new Promise((res) => setTimeout(res, 100));
return promise;
};

await render(<template><Button @onClick={{onClick}} @type="secondary"></Button></template>);
await render(
<template><Button @onClick={{onClick}} @type='secondary' /></template>,
);

await click('button');

Expand All @@ -38,25 +38,39 @@ module('Integration | Component | Button', (hooks) => {
await promise;
await settled();

assert.dom('.cds--loading').doesNotExist('should not show loading indicator');
assert
.dom('.cds--loading')
.doesNotExist('should not show loading indicator');
});

test('cannot click disabled', async function(assert) {
test('cannot click disabled', async function (assert) {
assert.expect(2);

const onClick = function() {
return new Promise(res => setTimeout(res, 1000));
const onClick = function () {
return new Promise((res) => setTimeout(res, 1000));
};

await render(<template><Button @onClick={{onClick}} @type="primary" @disabled={{true}}></Button></template>);
await render(
<template>
<Button @onClick={{onClick}} @type='primary' @disabled={{true}} />
</template>,
);

try {
await click('button');
} catch (e) {
assert.deepEqual(e.message, 'Can not `click` disabled [object HTMLButtonElement]', 'cannot click');
assert.deepEqual(
e.message,
'Can not `click` disabled [object HTMLButtonElement]',
'cannot click',
);
}

assert.dom('button').hasClass('cds--btn--disabled', 'class names should include cds--btn--disabled');
assert
.dom('button')
.hasClass(
'cds--btn--disabled',
'class names should include cds--btn--disabled',
);
});
});

0 comments on commit 79eb943

Please sign in to comment.