Skip to content

Commit

Permalink
Merge pull request #137 from ATIX-AG/feature/switch_to_foreman_gha
Browse files Browse the repository at this point in the history
Use theforeman github actions for JavaScript tests
  • Loading branch information
bastian-src authored Mar 27, 2024
2 parents 9a9ee52 + b38e4e0 commit af340c9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 18 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/js_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@ name: JavaScript Testing
on:
push:
branches:
- main
- master
pull_request:
paths:
- 'webpack/**'
- 'package.json'
- 'package-lock.json'
- '.github/workflows/js_tests.yml'

concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
test_js:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [12, 14]
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Npm install
run: npm install
- name: Run plugin linter
run: npm run lint
test:
name: JavaScript
uses: theforeman/actions/.github/workflows/foreman_plugin_js.yml@v0
with:
plugin: foreman_scc_manager
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"lint": "tfm-lint --plugin -d /webpack",
"test": "echo \"Error: no test specified\" && exit 1",
"test": "tfm-test --plugin",
"create-react-component": "yo react-domain"
},
"repository": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* eslint-disable promise/prefer-await-to-then */
// Configure Enzyme
import { mount, shallow } from '@theforeman/test';
import React from 'react';
import SCCGenericExpander from './index';

describe('SCCGenericExpander', () => {
it('renders default properties', () => {
const wrapper = mount(
<SCCGenericExpander
setInParent={() => {}}
selectOptionOpen="open"
selectOptionClose="close"
initLabel="open/close"
/>
);

expect(wrapper.find('SCCGenericExpander')).toHaveLength(1);
expect(wrapper.find('Flex')).toHaveLength(1);
expect(wrapper.find('FlexItem')).toHaveLength(1);
expect(wrapper.find('Select')).toHaveLength(1);
});

it('passes properties', () => {
const wrapper = shallow(
<SCCGenericExpander
setInParent={() => {}}
selectOptionOpen="open"
selectOptionClose="close"
initLabel="open/close"
/>
);

// Select
const select = wrapper.find('Select');
expect(select.exists()).toBe(true);
expect(select.props()).toHaveProperty('selections');
expect(select.prop('selections')).toContain('open/close');

// SelectOptions
const selectOptions = wrapper.find('SelectOption');
expect(selectOptions).toHaveLength(2);
const optionValues = selectOptions.map((option) => option.prop('value'));
expect(optionValues).toContain('open');
expect(optionValues).toContain('close');
});
});

0 comments on commit af340c9

Please sign in to comment.