Skip to content
This repository was archived by the owner on Jul 4, 2018. It is now read-only.

Commit 5ec4125

Browse files
authored
Merge pull request #58 from FoalTS/sequelize-connection-test
Add tests to SequelizeConnection services.
2 parents baf35d6 + b81a185 commit 5ec4125

File tree

6 files changed

+48
-3
lines changed

6 files changed

+48
-3
lines changed

generators/app/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Welcome to the FoalTS generator! The following questions will help you create yo
136136
if (this.database) {
137137
paths.push(
138138
'src/app/shared/connection.service.ts',
139+
'src/app/shared/connection.service.spec.ts',
139140
'src/app/shared/index.ts',
140141
)
141142
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { expect } from 'chai';
2+
3+
import { ConnectionService } from './connection.service';
4+
5+
describe('ConnectionService', () => {
6+
7+
describe('when it is instantiated', () => {
8+
9+
it('should connect to the database.', () => {
10+
expect(() => new ConnectionService()).not.to.throw();
11+
});
12+
13+
});
14+
15+
});

generators/service/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ module.exports = class extends Generator {
5151
underscoreName: `${this.names.kebabName.replace(/-/g,'_')}`
5252
}, this.names)
5353
);
54-
if (this.type !== 'local-authenticator' && this.type !== 'sequelize-model'
55-
&& this.type !== 'sequelize-connection') {
54+
if (this.type !== 'local-authenticator' && this.type !== 'sequelize-model') {
5655
this.fs.copyTpl(
5756
this.templatePath(`${this.type}-service.spec.ts`),
5857
this.destinationPath(`${this.names.kebabName}.service.spec.ts`),
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { expect } from 'chai';
2+
3+
import { <%= CamelName %>Service } from './<%= kebabName %>.service';
4+
5+
describe('<%= CamelName %>Service', () => {
6+
7+
describe('when it is instantiated', () => {
8+
9+
it('should connect to the database.', () => {
10+
expect(() => new <%= CamelName %>Service()).not.to.throw();
11+
});
12+
13+
});
14+
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { expect } from 'chai';
2+
3+
import { FooBarService } from './foo-bar.service';
4+
5+
describe('FooBarService', () => {
6+
7+
describe('when it is instantiated', () => {
8+
9+
it('should connect to the database.', () => {
10+
expect(() => new FooBarService()).not.to.throw();
11+
});
12+
13+
});
14+
15+
});

test/service/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function testWithName(name) {
3939
testWithType(name, 'ejs-template');
4040
testWithType(name, 'multiple-ejs-templates');
4141
testWithType(name, 'sequelize-model', false);
42-
testWithType(name, 'sequelize-connection', false);
42+
testWithType(name, 'sequelize-connection');
4343
testWithType(name, 'authenticator');
4444
testWithType(name, 'view');
4545
testWithType(name, 'multiple-views');

0 commit comments

Comments
 (0)