How to use the tiny-types.TinyTypeOf function in tiny-types

To help you get started, weā€™ve selected a few tiny-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jan-molak / serenity-js / packages / assertions / spec / expectations / equals.spec.ts View on Github external
describe('equals', () => {

    const Astrid = stage().theActorCalled('Astrid');

    class Name extends TinyTypeOf() {}

    given([
        { description: 'string',    expected: 'hello',          actual: 'hello'             },
        { description: 'number',    expected: 42,               actual: 42                  },
        { description: 'boolean',   expected: false,            actual: false               },
        { description: 'object',    expected: { k: 'v' },       actual: { k: 'v' }          },
        { description: 'TinyType',  expected: new Name('Jan'),  actual: new Name('Jan')     },
        { description: 'array',     expected: [ null, 2, '3' ], actual: [ null, 2, '3' ]    },
        { description: 'Date',      expected: new Date('Jan 27, 2019'), actual: new Date('Jan 27, 2019') },
    ]).
    it('compares the value of "actual" and "expected" and allows for the actor flow to continue when they match', ({ actual, expected }) => {
        return expect(Astrid.attemptsTo(
            Ensure.that(actual, equals(expected)),
        )).to.be.fulfilled;
    });
github jan-molak / serenity-js / packages / core / src / io / FileExtension.ts View on Github external
import { TinyType, TinyTypeOf } from 'tiny-types';

export class FileExtension extends TinyTypeOf() {
    static JSON = new FileExtension('json');
    static PNG = new FileExtension('png');
    static fromJSON = (v: string) => new FileExtension(v);
}
github jan-molak / serenity-js / packages / core / src / io / MimeType.ts View on Github external
import { TinyType, TinyTypeOf } from 'tiny-types';

export class MimeType extends TinyTypeOf() {
    public static Application_JSON = new MimeType('application/json');
    public static Image_PNG = new MimeType('image/png');
    public static fromJSON = (v: string) => new MimeType(v);
}