2020-10-27 11:27:17 +01:00
|
|
|
'use strict';
|
|
|
|
|
2020-01-27 16:58:20 +01:00
|
|
|
const { toPlural, toSingular, toInputName } = require('../naming');
|
|
|
|
|
|
|
|
describe('Name util', () => {
|
|
|
|
it('Pluralizes with camelcase', () => {
|
|
|
|
expect(toPlural('post')).toBe('posts');
|
|
|
|
expect(toPlural('posts')).toBe('posts');
|
|
|
|
expect(toPlural('Posts')).toBe('posts');
|
|
|
|
expect(toPlural('home-page')).toBe('homePages');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Casts to singular with camelcase', () => {
|
|
|
|
expect(toSingular('post')).toBe('post');
|
|
|
|
expect(toSingular('posts')).toBe('post');
|
|
|
|
expect(toSingular('Posts')).toBe('post');
|
|
|
|
expect(toSingular('home-pages')).toBe('homePage');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Generates valid input type names', () => {
|
|
|
|
expect(toInputName('post')).toBe('PostInput');
|
|
|
|
expect(toInputName('posts')).toBe('PostInput');
|
|
|
|
expect(toInputName('home-page')).toBe('HomePageInput');
|
|
|
|
});
|
|
|
|
});
|