How to use the mocha-typescript.suite function in mocha-typescript

To help you get started, we’ve selected a few mocha-typescript 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 hipages / inceptum / test / ioc / Decorators.ts View on Github external
suite('ioc/Decorators', () => {
  suite('Autowire', () => {
    test('Autowire gets called', () => {
      // const val = new Test1();
      Reflect.hasMetadata('inceptum', Test1.prototype).must.be.true();
      const metadata = Reflect.getMetadata('inceptum', Test1.prototype);
      metadata.autowire.get('prop1').must.equal('the value');
    });
  });
  suite('Lazy', () => {
    test('Lazy gets called', () => {
      // const val = new Test1();
      Reflect.hasMetadata('inceptum', Test1.prototype).must.be.true();
      const metadata = Reflect.getMetadata('inceptum', Test1.prototype);
      metadata.lazy.must.be.false();
    });
  });
  suite('Groups', () => {
    test('Groups are Autowired', async () => {
      const context = new Context('test1');
      context.addObjectDefinitionInspector(new ObjectDefinitionDecoratorInspector());
      context.registerDefinition(new BaseSingletonDefinition(Wired1));
      context.registerDefinition(new BaseSingletonDefinition(Wired2));
      context.registerDefinition(new BaseSingletonDefinition(Wired3));
      context.registerDefinition(new BaseSingletonDefinition(WireInto));
      await context.lcStart();
github hipages / inceptum / test / ioc / objectdefinition / BaseSingletonDefinition.ts View on Github external
});
    test('If trace contains me, there\'s a Circular Dependency', () => {
      const def = new BaseSingletonDefinition<a>(A);
      try {
        def.checkConstructorCircularDependency(['hsd', 'A']);
        false.must.be.true();
      } catch (e) {
        e.must.be.an.error(/Circular dependency detected/);
      }
    });
    test('If trace doesn\'t contains me, there\'s no Circular Dependency', () =&gt; {
      const def = new BaseSingletonDefinition</a><a>(A);
      def.checkConstructorCircularDependency(['hsd', 'B']);
    });
  });
  suite('getInstance', () =&gt; {
    test('get simple instance', () =&gt; {
      const contextMock = MockUtil.mock(Context);
      // const contextMock = new Object();
      const defA = new BaseSingletonDefinition</a><a>(A);
      defA.setContext(contextMock);

      const promise = defA.getInstance()
      .then((instance) =&gt; {
        instance.must.not.be.falsy();
      });
      return promise;
    });
    test('get instance with constructor dep', () =&gt; {
      const contextMock = MockUtil.mock(Context);
      // const contextMock = new Object();
      const defA = new BaseSingletonDefinition</a><a>(A);</a>
github hipages / inceptum / test / health / HealthCheck.ts View on Github external
suite('HealthCheckGroup', () =&gt; {
    suite('Grouping', () =&gt; {
      test('adding simple test adds it directly', () =&gt; {
        const group = new HealthCheckGroup('test1');
        const mockHealthCheck = mock(HealthCheck);
        when(mockHealthCheck.getCheckName()).thenReturn('simpleId');
        group.addCheck(instance(mockHealthCheck));
        group.healthChecks.size.must.equal(1);
        Array.from(group.healthChecks.keys()).must.eql(['simpleId']);
      });
      test('adding 2nd level test adds it to a group', () =&gt; {
        const group = new HealthCheckGroup('test1');
        const mockHealthCheck = mock(HealthCheck);
        when(mockHealthCheck.getCheckName()).thenReturn('simpleId.subtest');
        group.addCheck(instance(mockHealthCheck));
        group.healthChecks.size.must.equal(1);
        Array.from(group.healthChecks.keys()).must.eql(['simpleId']);
        const simpleIdGroup = group.healthChecks.get('simpleId');
github hipages / inceptum / test / health / HealthCheck.ts View on Github external
group.healthChecks.size.must.equal(1);
        Array.from(group.healthChecks.keys()).must.eql(['simpleId']);
        const simpleIdGroup = group.healthChecks.get('simpleId');
        simpleIdGroup.must.be.instanceOf(HealthCheckGroup);
        const asGroup = simpleIdGroup as HealthCheckGroup;
        asGroup.healthChecks.size.must.equal(1);
        Array.from(asGroup.healthChecks.keys()).must.eql(['subtest']);

        const simpleIdGroup2 = asGroup.healthChecks.get('subtest');
        simpleIdGroup2.must.be.instanceOf(HealthCheckGroup);
        const asGroup2 = simpleIdGroup2 as HealthCheckGroup;
        asGroup2.healthChecks.size.must.equal(1);
        Array.from(asGroup2.healthChecks.keys()).must.eql(['subsubtest']);
      });
    });
    suite('Lifecycle', () =&gt; {
      test('starting the group starts the checks', () =&gt; {
        const group = new HealthCheckGroup('test1');
        const mockHealthCheck = mock(HealthCheck);
        when(mockHealthCheck.getCheckName()).thenReturn('simpleId');
        group.addCheck(instance(mockHealthCheck));
        group.start();
        verify(mockHealthCheck.start()).once();
        group.stop();
      });
      test('stopping the group stops the checks', () =&gt; {
        const group = new HealthCheckGroup('test1');
        const mockHealthCheck = mock(HealthCheck);
        when(mockHealthCheck.getCheckName()).thenReturn('simpleId');
        group.addCheck(instance(mockHealthCheck));
        group.start();
        verify(mockHealthCheck.start()).once();
github georgehanson / Vue-Form-Components / tests / select-list.spec.ts View on Github external
import { suite, test, slow, timeout } from "mocha-typescript";
import {mount} from "avoriaz";
import SelectList from "./../src/select-list.ts";
import expect from 'expect';
import {StandardSlot} from "./resources.ts";
import sinon from 'sinon';

suite("SelectList", () => {
    test("it can set the name", () => {
        let wrapper: any = mount(SelectList, {
            propsData: {
                name: 'title'
            }
        });

        expect(wrapper.first('select').hasAttribute('name')).toBe(true);
        expect(wrapper.first('select').getAttribute('name')).toBe('title');
    });

    test("the label gets output", () => {
        let wrapper: any = mount(SelectList, {
            propsData: {
                name: 'title',
                label: 'My Input'
github hipages / inceptum / test / ioc / Context.ts View on Github external
suite('ioc/Context', () => {
  suite('inheritance', () => {
    test('starting the child context starts the parent context', () => {
      const parentContext = new Context('parent context');
      const childContext = new Context('child context', parentContext);
      return childContext.lcStart()
        .then(() => {
          childContext.getStatus().must.be.equal(LifecycleState.STARTED);
          parentContext.getStatus().must.be.equal(LifecycleState.STARTED);
        })
        .then(() => childContext.lcStop());
    });
    test('stopping the child context stops the parent context', () => {
      const parentContext = new Context('parent context');
      const childContext = new Context('child context', parentContext);
      return childContext.lcStart()
        .then(() => childContext.lcStop())
        .then(() => {
github hipages / inceptum / test / ioc / Context.ts View on Github external
const myContext = new Context('test1');
      myContext.registerSingletons(new BaseSingletonDefinition(A).constructorParamByRef('B'));
      myContext.registerSingletons(new BaseSingletonDefinition(B).constructorParamByRef('A'));

      return myContext.lcStart()
        .then(() => myContext.getObjectByName('A'))
        .then(() => {
          throw new Error('Shouldn\'t be here');
        })
        .catch((err) => {
          err.must.be.an.error(/Circular dependency detected/);
        })
        .then(() => myContext.lcStop());
    });
  });
  suite('cloning', () => {
    test('throws an exception when in any state other than NOT_STARTED', () => {
      const myContext = new Context('test1');
      return myContext.lcStart()
        .then(() => myContext.clone('copy'))
        .catch((err) => err.must.be.an.error(/Operation requires state to be/))
        .then(() => myContext.lcStop());
    });
    test('clones all object definitions', () => {
      const myContext = new Context('test1');
      myContext.registerSingletons(new BaseSingletonDefinition(A).constructorParamByValue('the value'));

      const clonedContext = myContext.clone('test2');

      return myContext.lcStart()
        .then(() => clonedContext.lcStart())
        .then(() => PromiseUtil.mapSeries([myContext, clonedContext], (c) => c.getObjectByName('A')))
github hipages / inceptum / test / ioc / Context.ts View on Github external
const myContext = new Context('test1');
      myContext.registerSingletons(new BaseSingletonDefinition(A));
      myContext.registerSingletons(new BaseSingletonDefinition(B).setPropertyByDefinitionGroup('a', 'myGroup'));
      myContext.addObjectNameToGroup('myGroup', 'A');
      await myContext.lcStart();
      const b: B = await myContext.getObjectByName('B');
      (b === undefined).must.be.false();
      (b.a === undefined).must.be.false();
      b.a.must.be.an.array();
      b.a.length.must.equal(1);
      (b.a[0] instanceof BaseSingletonDefinition).must.be.true();
      (b.a[0] as any as BaseSingletonDefinition).getName().must.equal('A');
      await myContext.lcStop();
    });
  });
  suite('wiring', () =&gt; {
    test('can manage circular dependencies', () =&gt; {
      const myContext = new Context('test1');
      myContext.registerSingletons(new BaseSingletonDefinition<a>(A).constructorParamByRef('B'));
      myContext.registerSingletons(new BaseSingletonDefinition<b>(B).setPropertyByRef('a', 'A'));
      return myContext.lcStart()
        .then(() =&gt; PromiseUtil.map(['A', 'B'], (n) =&gt; myContext.getObjectByName(n)))
        .then(([a, b]) =&gt; {
          (a === undefined).must.be.false();
          (b === undefined).must.be.false();
          (a.val === undefined).must.be.false();
          a.val.must.be.equal(b);
          return [a, b];
        })
        .then((v) =&gt; PromiseUtil.sleepPromise(20, v))
        .then(([a, b]) =&gt; {
          b.a.must.be.equal(a);</b></a>
github ProjectOpenSea / opensea-js / test / api.ts View on Github external
import {
  assert,
} from 'chai'

import {
  suite,
  test,
  skip,
} from 'mocha-typescript'

import { ORDERBOOK_VERSION } from '../src/api'
import { Order, OrderSide, OrderJSON } from '../src/types'
import { orderToJSON } from '../src'
import { mainApi, rinkebyApi, apiToTest, ALEX_ADDRESS, CK_RINKEBY_TOKEN_ID, CK_RINKEBY_ADDRESS, CK_RINKEBY_SELLER_FEE } from './constants'

suite('api', () => {

  test('API has correct base url', () => {
    assert.equal(mainApi.apiBaseUrl, 'https://api.opensea.io')
    assert.equal(rinkebyApi.apiBaseUrl, 'https://rinkeby-api.opensea.io')
  })

  test('API fetches bundles and prefetches sell orders', async () => {
    const { bundles } = await apiToTest.getBundles({asset_contract_address: CK_RINKEBY_ADDRESS, on_sale: true})
    assert.isArray(bundles)

    const bundle = bundles[0]
    assert.isNotNull(bundle)
    if (!bundle) {
      return
    }
    assert.include(bundle.assets.map(a => a.assetContract.name), "CryptoKittiesRinkeby")
github seagull-js / seagull / test / unit / scaffold / generators / json_tslint.ts View on Github external
import { JsonTslint } from '@scaffold/generators'
import { expect } from 'chai'
import { skip, slow, suite, test, timeout } from 'mocha-typescript'
import { join } from 'path'

@suite('Unit::Scaffold::JsonTslint')
class Test {
  @test
  'can be initialized'() {
    const gen = JsonTslint()
    expect(gen).to.be.an('object')
  }
}

mocha-typescript

TypeScript decorators based wrapper over mocha's interface

Apache-2.0
Latest version published 6 years ago

Package Health Score

45 / 100
Full package analysis

Popular mocha-typescript functions

Similar packages