2021-04-29 12:03:54 +02:00

26 lines
820 B
JavaScript

'use strict';
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');
});
});