Skip to content

Commit

Permalink
Added truncate method to blog test
Browse files Browse the repository at this point in the history
  • Loading branch information
bashleigh committed Oct 31, 2018
1 parent 451b80e commit f6228a7
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/blog/slug.provider.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Test, TestingModule } from '@nestjs/testing';
import {SlugProvider} from './slug.provider';
import {ConfigModule, ConfigService} from 'nestjs-config';
import * as path from 'path';
import { INestApplication } from '@nestjs/common';

let module: TestingModule;
let app: INestApplication;
let slugProvider: SlugProvider;
let config: ConfigService;

describe('SlugProvider', async () => {
beforeAll(async () => {
module = await Test.createTestingModule({
imports: [
ConfigModule.load(path.resolve(__dirname, '../', 'config', '*.ts')),
],
providers: [SlugProvider],
}).compile();

app = module.createNestApplication();
await app.init();

slugProvider = module.get(SlugProvider);
config = module.get(ConfigService);
});

it('replacement', () => {
expect(slugProvider.replacement()).toEqual(config.get('slugify.replacement'));
});

it('slugify', () => {
expect(slugProvider.slugify('test test')).toEqual('test-test');
});
});

0 comments on commit f6228a7

Please sign in to comment.