Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/pipeline_wizard/components/widgets_spec.js')
-rw-r--r--spec/frontend/pipeline_wizard/components/widgets_spec.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/frontend/pipeline_wizard/components/widgets_spec.js b/spec/frontend/pipeline_wizard/components/widgets_spec.js
new file mode 100644
index 00000000000..5944c76c5d0
--- /dev/null
+++ b/spec/frontend/pipeline_wizard/components/widgets_spec.js
@@ -0,0 +1,49 @@
+import fs from 'fs';
+import { mount } from '@vue/test-utils';
+import { Document } from 'yaml';
+import InputWrapper from '~/pipeline_wizard/components/input.vue';
+
+describe('Test all widgets in ./widgets/* whether they provide a minimal api', () => {
+ const createComponent = (props = {}, mountFunc = mount) => {
+ mountFunc(InputWrapper, {
+ propsData: {
+ template: new Document({
+ template: {
+ bar: 'baz',
+ foo: { some: '$TARGET' },
+ },
+ }).get('template'),
+ compiled: new Document({ bar: 'baz', foo: { some: '$TARGET' } }),
+ target: '$TARGET',
+ widget: 'text',
+ label: 'some label (required by the text widget)',
+ ...props,
+ },
+ });
+ };
+
+ const widgets = fs
+ .readdirSync('./app/assets/javascripts/pipeline_wizard/components/widgets')
+ .map((filename) => [filename.match(/^(.*).vue$/)[1]]);
+ let consoleErrorSpy;
+
+ beforeAll(() => {
+ consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
+ });
+
+ afterAll(() => {
+ consoleErrorSpy.mockRestore();
+ });
+
+ describe.each(widgets)('`%s` Widget', (name) => {
+ it('passes the input validator', () => {
+ const validatorFunc = InputWrapper.props.widget.validator;
+ expect(validatorFunc(name)).toBe(true);
+ });
+
+ it('mounts without error', () => {
+ createComponent({ widget: name });
+ expect(consoleErrorSpy).not.toHaveBeenCalled();
+ });
+ });
+});