swimlane/ngx-ui

View on GitHub
projects/swimlane/ngx-ui/src/lib/utils/position/horizontal-position/horizontal-position.util.spec.ts

Summary

Maintainability
C
1 day
Test Coverage
import { horizontalPosition } from './horizontal-position.util';
import { CARET_OFFSET } from '../caret-offset.constant';
import { AlignmentTypes } from '../alignment-types.enum';

describe('horizontalPosition', () => {
  it('should get left', () => {
    expect(horizontalPosition({ left: 10 }, {}, AlignmentTypes.left)).toEqual(10 - CARET_OFFSET);
  });

  it('should get right', () => {
    expect(horizontalPosition({ left: 10, width: 10 }, { width: 10 }, AlignmentTypes.right)).toEqual(10 + CARET_OFFSET);
  });

  it('should get center', () => {
    expect(horizontalPosition({ left: 10, width: 10 }, { width: 10 }, AlignmentTypes.center)).toEqual(10);
  });

  it('should do nothing when not horizontally aligned', () => {
    expect(horizontalPosition({ left: 10, width: 10 }, { width: 10 }, AlignmentTypes.top)).toBeUndefined();
  });
});