UNPKG

@lastlight/typeorm-cursor-pagination

Version:
24 lines (17 loc) 769 B
import { expect } from 'chai'; import { encodeByType, decodeByType } from '../src/utils'; describe('Reflect.getMetadata Date type is Object test', () => { it('should encode cursor correctly with object type and date value', () => { const date = new Date(); const encoded = encodeByType('object', date); expect(encoded).to.be.a('string'); }); it('should decode cursor correctly with object type and date string value', () => { const value = new Date().getTime().toString(); const decoded = decodeByType('object', value); expect(decoded).to.be.a('date'); }); it('should throw error with object type and non date value', () => { expect(() => encodeByType('object', { foo: 'bar' })).to.throw(/unknown type in cursor/); }); });