Skip to content

Commit

Permalink
test: add some extra test around stackblitz services
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefiozie authored and manekinekko committed Mar 10, 2019
1 parent 275a679 commit edb3253
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 1 deletion.
Expand Up @@ -18,7 +18,7 @@ describe('CodeGenService', () => {
});
});

xit('should be created', inject(
it('should be created', inject(
[CodeGenService],
(service: CodeGenService) => {
expect(service).toBeTruthy();
Expand Down
@@ -0,0 +1,49 @@
import { XlayersNgxEditorModel } from '@app/editor/code-editor/editor-container/codegen/codegen.service';
import { ExportStackblitzAngularService } from './stackblitz.angular.service';

describe('StackBlitz Angular', () => {
let service: ExportStackblitzAngularService;
let files, template, tags;
const model: XlayersNgxEditorModel = {
kind: 'angular',
uri: 'uri',
value: 'string',
language: 'angular'
};
beforeEach(() => {
service = new ExportStackblitzAngularService();
const result = service.prepare([model]);
files = result.files;
tags = result.tags;
template = result.template;
});

it('should be created', () => {
expect(service).toBeTruthy();
});

it('should contain 5 files', () => {
expect(Object.keys(files).length).toBe(5);
});


it('should contain a app.component', () => {
expect(files['src/app/app.component.ts']).toBeTruthy();
});

it('should contain uri files', () => {
expect(files['src/app/xlayers/uri']).toBe('string');
});

it('should have default index.html', () => {
expect(files['src/index.html']).toBe('<my-app>loading</my-app>');
});

it('should have angular tag', () => {
expect(tags).toEqual(['angular']);
});

it('should have angular-cli template', () => {
expect(template).toBe('angular-cli');
});
});
@@ -0,0 +1,45 @@
import { XlayersNgxEditorModel } from '@app/editor/code-editor/editor-container/codegen/codegen.service';
import { ExportStackblitzLitElementService } from './stackblitz.lit-element.service';

describe('StackBlitz Lit Element', () => {
let service: ExportStackblitzLitElementService;
let files, template, tags;
const model: XlayersNgxEditorModel = {
kind: 'litElement',
uri: 'uri',
value: 'string',
language: 'lit'
};

beforeEach(() => {
service = new ExportStackblitzLitElementService();
const result = service.prepare([model]);
files = result.files;
tags = result.tags;
template = result.template;
});

it('should be created', () => {
expect(service).toBeTruthy();
});

it('should contain 3 files', () => {
expect(Object.keys(files).length).toBe(3);
});

it('should contain uri files', () => {
expect(files['uri']).toBe('string');
});

it('should have default index.js', () => {
expect(files['index.js']).toBe(`import './x-layers-element.js';`);
});

it('should have web component and lit-element tag', () => {
expect(tags).toEqual(['web component', 'lit-element']);
});

it('should have javascript template', () => {
expect(template).toBe('javascript');
});
});
@@ -0,0 +1,49 @@
import { XlayersNgxEditorModel } from '@app/editor/code-editor/editor-container/codegen/codegen.service';
import { ExportStackblitzReactService } from './stackblitz.react.service';

describe('StackBlitz React', () => {
let service: ExportStackblitzReactService;
let files, template, tags;
const model: XlayersNgxEditorModel = {
kind: 'react',
uri: 'uri',
value: 'string',
language: 'react'
};
beforeEach(() => {
service = new ExportStackblitzReactService();
const result = service.prepare([model]);
files = result.files;
tags = result.tags;
template = result.template;
});

it('should be created', () => {
expect(service).toBeTruthy();
});

it('should contain 4 files', () => {
expect(Object.keys(files).length).toBe(4);
});


it('should have default index file', () => {
expect(files['src/index.js']).toBeTruthy();
});

it('should contain uri files', () => {
expect(files['src/uri']).toBe('string');
});

it('should have default index.html', () => {
expect(files['public/index.html']).toBeTruthy();
});

it('should have react tag', () => {
expect(tags).toEqual(['react']);
});

it('should have create-react-app template', () => {
expect(template).toBe('create-react-app');
});
});

0 comments on commit edb3253

Please sign in to comment.