Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Apr 14, 2024
1 parent baeecdc commit 8ba5fda
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 201 deletions.
2 changes: 1 addition & 1 deletion packages/altair-app/jest.config.js
Expand Up @@ -16,6 +16,6 @@ module.exports = {
setupFilesAfterEnv: ['<rootDir>/src/setup-jest.ts'],
moduleDirectories: ['node_modules', '<rootDir>/src'],
transformIgnorePatterns: [
'node_modules/(?!@angular|@firebase|@ngrx|@sentry|lodash-es|altair-graphql-core|angular-resizable-element|dexie|uuid|ngx-cookie-service|ngx-markdown|ky|color-name|json-schema-library|graphql-language-service|vscode-languageserver-types|cm6-graphql|ngx-toastr|@ngx-translate|lucide-angular|@ctrl/ngx-codemirror|ng-zorro-antd|@ant-design/icons-angular|ngx-pipes)',
'node_modules/(?!@angular|@firebase|@ngrx|@sentry|lodash-es|altair-graphql-core|angular-resizable-element|dexie|uuid|ngx-cookie-service|ngx-markdown|ky|color-name|json-schema-library|graphql-language-service|vscode-languageserver-types|cm6-graphql|ngx-toastr|@ngx-translate|lucide-angular|ng-zorro-antd|@ant-design/icons-angular|ngx-pipes)',
],
};
Expand Up @@ -2,7 +2,6 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';

import { EnvironmentManagerComponent } from './environment-manager.component';
import { FormsModule } from '@angular/forms';
import { CodemirrorModule } from '@ctrl/ngx-codemirror';
import { TranslateModule } from '@ngx-translate/core';
import { SharedModule } from '../../modules/shared/shared.module';
import {
Expand All @@ -15,21 +14,18 @@ describe('EnvironmentManagerComponent', () => {
let component: EnvironmentManagerComponent;
let fixture: ComponentFixture<EnvironmentManagerComponent>;

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [EnvironmentManagerComponent, CodemirrorComponent],
imports: [
NoopAnimationsModule,
FormsModule,
CodemirrorModule,
SharedModule,
TranslateModule.forRoot(),
],
teardown: { destroyAfterEach: false },
}).compileComponents();
})
);
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [EnvironmentManagerComponent, CodemirrorComponent],
imports: [
NoopAnimationsModule,
FormsModule,
SharedModule,
TranslateModule.forRoot(),
],
teardown: { destroyAfterEach: false },
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(EnvironmentManagerComponent);
Expand Down
Expand Up @@ -12,18 +12,11 @@ exports[`QueryEditorComponent should render correctly 1`] = `
<div
class="query-editor-container"
>
<app-beta-indicator
description="This is a complete replacement of the old editor which allows more possibilities. It also comes with some new improvements and features."
featurekey="newEditor"
title="New editor"
/>
<app-codemirror
class="query-editor__input"
ngdefaultcontrol=""
/>
</div>
<div
class="variables-editor-container"
Expand Down
Expand Up @@ -35,9 +35,6 @@ describe('QueryEditorComponent', () => {
},
],
schemas: [NO_ERRORS_SCHEMA],
propsData: {
betaDisableNewEditor: false,
},
});
});

Expand Down
@@ -1,7 +1,6 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';

import { FormsModule } from '@angular/forms';
import { CodemirrorModule } from '@ctrl/ngx-codemirror';
import { TranslateModule } from '@ngx-translate/core';

import { ComponentModule } from '../../components/components.module';
Expand All @@ -12,19 +11,12 @@ describe('QueryResultComponent', () => {
let component: QueryResultComponent;
let fixture: ComponentFixture<QueryResultComponent>;

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
FormsModule,
CodemirrorModule,
ComponentModule,
TranslateModule.forRoot(),
],
teardown: { destroyAfterEach: false },
}).compileComponents();
})
);
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [FormsModule, ComponentModule, TranslateModule.forRoot()],
teardown: { destroyAfterEach: false },
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(QueryResultComponent);
Expand Down
@@ -1,7 +1,6 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';

import { FormsModule } from '@angular/forms';
import { CodemirrorModule } from '@ctrl/ngx-codemirror';
import { TranslateModule } from '@ngx-translate/core';

import { SetVariableDialogComponent } from './set-variable-dialog.component';
Expand All @@ -13,22 +12,19 @@ describe('SetVariableDialogComponent', () => {
let component: SetVariableDialogComponent;
let fixture: ComponentFixture<SetVariableDialogComponent>;

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [SetVariableDialogComponent, VariablesEditorComponent],
imports: [
NoopAnimationsModule,
FormsModule,
CodemirrorModule,
SharedModule,
TranslateModule.forRoot(),
],
providers: [],
teardown: { destroyAfterEach: false },
}).compileComponents();
})
);
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [SetVariableDialogComponent, VariablesEditorComponent],
imports: [
NoopAnimationsModule,
FormsModule,
SharedModule,
TranslateModule.forRoot(),
],
providers: [],
teardown: { destroyAfterEach: false },
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(SetVariableDialogComponent);
Expand Down
Expand Up @@ -2,7 +2,6 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';

import { empty as observableEmpty } from 'rxjs';
import { FormsModule } from '@angular/forms';
import { CodemirrorModule } from '@ctrl/ngx-codemirror';
import { TranslateModule } from '@ngx-translate/core';

import { SettingsDialogComponent } from './settings-dialog.component';
Expand Down Expand Up @@ -30,45 +29,42 @@ describe('SettingsDialogComponent', () => {
let component: SettingsDialogComponent;
let fixture: ComponentFixture<SettingsDialogComponent>;

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [SettingsDialogComponent],
imports: [
HttpClientModule,
NoopAnimationsModule,
FormsModule,
CodemirrorModule,
SharedModule,
TranslateModule.forRoot(),
SchemaFormModule,
],
providers: [
MockProviders(NotifyService),
KeybinderService,
MockProviders(WindowService),
DbService,
ElectronAppService,
StorageService,
GqlService,
{
provide: Store,
useValue: {
subscribe: () => {},
select: () => [],
map: () => observableEmpty(),
dispatch: () => {},
},
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [SettingsDialogComponent],
imports: [
HttpClientModule,
NoopAnimationsModule,
FormsModule,
SharedModule,
TranslateModule.forRoot(),
SchemaFormModule,
],
providers: [
MockProviders(NotifyService),
KeybinderService,
MockProviders(WindowService),
DbService,
ElectronAppService,
StorageService,
GqlService,
{
provide: Store,
useValue: {
subscribe: () => {},
select: () => [],
map: () => observableEmpty(),
dispatch: () => {},
},
{
provide: AltairConfig,
useValue: new AltairConfig(),
},
],
teardown: { destroyAfterEach: false },
}).compileComponents();
})
);
},
{
provide: AltairConfig,
useValue: new AltairConfig(),
},
],
teardown: { destroyAfterEach: false },
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(SettingsDialogComponent);
Expand Down
@@ -1,7 +1,6 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';

import { FormsModule } from '@angular/forms';
import { CodemirrorModule } from '@ctrl/ngx-codemirror';
import { TranslateModule } from '@ngx-translate/core';

import { SubscriptionUrlDialogComponent } from './subscription-url-dialog.component';
Expand All @@ -14,22 +13,19 @@ describe('SubscriptionUrlDialogComponent', () => {
let component: SubscriptionUrlDialogComponent;
let fixture: ComponentFixture<SubscriptionUrlDialogComponent>;

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [SubscriptionUrlDialogComponent, CodemirrorComponent],
imports: [
NoopAnimationsModule,
FormsModule,
CodemirrorModule,
SharedModule,
TranslateModule.forRoot(),
SharedModule,
],
teardown: { destroyAfterEach: false },
}).compileComponents();
})
);
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [SubscriptionUrlDialogComponent, CodemirrorComponent],
imports: [
NoopAnimationsModule,
FormsModule,
SharedModule,
TranslateModule.forRoot(),
SharedModule,
],
teardown: { destroyAfterEach: false },
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(SubscriptionUrlDialogComponent);
Expand Down
Expand Up @@ -2,11 +2,9 @@

exports[`VariablesEditorComponent should render correctly 1`] = `
<app-variables-editor>
<ngx-codemirror
<app-codemirror
class="set-variable-textarea mousetrap"
/>
</app-variables-editor>
`;
Expand Up @@ -24,26 +24,4 @@ describe('VariablesEditorComponent', () => {
it('should render correctly', () => {
expect(wrapper.element).toMatchSnapshot();
});

it('should pass editor config to codemirror instance as options', () => {
expect(wrapper.find('ngx-codemirror').props('options').mode).toBe(
'graphql-variables'
);
});

it('should update tabSize passed to codemirror when it changes', async () => {
wrapper.setProps({
tabSize: 2,
});

await wrapper.nextTick();
expect(wrapper.find('ngx-codemirror').props('options').tabSize).toBe(2);

wrapper.setProps({
tabSize: 4,
});

await wrapper.nextTick();
expect(wrapper.find('ngx-codemirror').props('options').tabSize).toBe(4);
});
});

0 comments on commit 8ba5fda

Please sign in to comment.