How to use alsatian - 10 common examples

To help you get started, we’ve selected a few alsatian 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 TypeScriptToLua / TypeScriptToLua / test / integration / lua / modules.spec.ts View on Github external
public lualibRequire() {
        // Transpile
        let lua = util.transpileString(``, {dontRequireLuaLib: false, luaTarget: "JIT"});

        // Assert
        Expect(dedent(lua)).toBe(`require("typescript_lualib")`);
    }
}
github poetapp / node / test / Unit / ClaimHelper / GetClaimId.ts View on Github external
public claimIdIgnoresId(work: Work) {
    // The field .id is ignored in the calculation of the id
    const ignoreId = getClaimId({
      ...work,
      id: '123'
    })
    Expect(ignoreId).toBe(work.id)
  }
github poetapp / poet-js / test / Claim / GetClaimId.ts View on Github external
public claimIdIgnoresId(work: Work) {
    // The field .id is ignored in the calculation of the id
    const ignoreId = getClaimId({
      ...work,
      id: '123',
    })
    Expect(ignoreId).toBe(work.id)
  }
github TypeScriptToLua / TypeScriptToLua / test / unit / cli.spec.ts View on Github external
import { Expect, Test, TestCase } from "alsatian";

import { findConfigFile, parseCommandLine } from "../../src/CommandLineParser";

export class CLITests {

    @Test("defaultOption")
    @TestCase("luaTarget", "JIT")
    @TestCase("noHeader", false)
    @TestCase("luaLibImport", "inline")
    @TestCase("rootDir", process.cwd())
    @TestCase("outDir", process.cwd())
    public defaultOptions(option: any, expected: any): void {
        const parsedCommandLine = parseCommandLine([]);

        Expect(expected).toBe(parsedCommandLine.options[option]);
    }

    @Test("ValidLuaTarget")
    public validLuaTarget(): void {
        const parsedCommandLine = parseCommandLine(['--luaTarget', '5.3']);
        Expect(parsedCommandLine.options["luaTarget"]).toBe("5.3");
    }

    @Test("InvalidLuaTarget")
    public invalidLuaTarget(): void {
        // Don't check error message because the yargs library messes the message up.
        Expect(() => parseCommandLine(['--luaTarget', '42'])).toThrow();
github TypeScriptToLua / TypeScriptToLua / test / unit / cli.spec.ts View on Github external
import { Expect, Test, TestCase } from "alsatian";

import { findConfigFile, parseCommandLine } from "../../src/CommandLineParser";

export class CLITests {

    @Test("defaultOption")
    @TestCase("luaTarget", "JIT")
    @TestCase("noHeader", false)
    @TestCase("luaLibImport", "inline")
    @TestCase("rootDir", process.cwd())
    @TestCase("outDir", process.cwd())
    public defaultOptions(option: any, expected: any): void {
        const parsedCommandLine = parseCommandLine([]);

        Expect(expected).toBe(parsedCommandLine.options[option]);
    }

    @Test("ValidLuaTarget")
    public validLuaTarget(): void {
        const parsedCommandLine = parseCommandLine(['--luaTarget', '5.3']);
        Expect(parsedCommandLine.options["luaTarget"]).toBe("5.3");
    }

    @Test("InvalidLuaTarget")
    public invalidLuaTarget(): void {
        // Don't check error message because the yargs library messes the message up.
github 01alchemist / TurboScript / debug / turboscript.spec__.ts View on Github external
* Called once after every test
     */
    @Teardown
    public teardown() {
        debug("teardown:+");

        // Add code

        debug("teardown:-");
    }

    /**
     * An example synchronous test which adds two numbers using TypeScript
     */
    @TestCase(1, 2, 3)
    @TestCase(-1, 2, 1)
    @TestCase(0, 0, 0)
    @Test("Test adding two numbers using TypeScript")
    public testAddTwoTypeScript(val1: number, val2: number, expectedResult: number) {
        debug("testAddTwoTypeScript:+");

        Expect(val1 + val2).toBe(expectedResult);

        debug("testAddTwoTypeScript:-");
    }

    /**
     * Test TurboScript can add numbers
     */
    @TestCase(1, 2, 3)
    @TestCase(-1, 2, 1)
    @TestCase(0, 0, 0)
github nozzlegear / Shopify-Prime / tests / application_credits.ts View on Github external
TestFixture,
    Timeout
    } from 'alsatian';
import { Config, Expect } from './test_utils';

@TestFixture("Application Credits")
export class ApplicationCreditTests {
    @AsyncTest("Creates an application credit")
    @IgnoreTest("Cannot be tested with a private app.")
    public async Test1() { }

    @AsyncTest("Gets an application credit")
    @IgnoreTest("Cannot be tested with a private app.")
    public async Test2() { }

    @AsyncTest("Lists application credits")
    @IgnoreTest("Cannot be tested with a private app.")
    public async Test3() { }
}
github nozzlegear / Shopify-Prime / tests / shops.ts View on Github external
Expect(shop.force_ssl).toBeType("boolean");
        Expect(shop.shop_owner).toBeType("string");
        Expect(shop.myshopify_domain).toBeType("string");
    }

    @AsyncTest("should get a shop with only a name field")
    @Timeout(5000)
    public async Test2() {
        const shop = await this.service.get({ fields: "name" });

        Expect(shop).not.toBeNull();
        Expect(Object.getOwnPropertyNames(shop).length).toEqual(1);
        Expect(shop.name).toBeType("string");
    }

    @AsyncTest("should force uninstall the app") 
    @IgnoreTest("cannot be tested with a private app")
    public async Test3() { }
}
github nozzlegear / Shopify-Prime / tests / charges.ts View on Github external
TestFixture,
    Timeout
    } from 'alsatian';
import { Config, Expect } from './test_utils';

@TestFixture("Charge Tests")
export class ChargeTests {
    @AsyncTest("should list charges,")
    @IgnoreTest("Cannot be tested with a private app.")
    public async Test1() { }

    @AsyncTest("should get a charge")
    @IgnoreTest("Cannot be tested with a private app.")
    public async Test2() { }

    @AsyncTest("should create a charge")
    @IgnoreTest("Cannot be tested with a private app.")
    public async Test3() { }

    @AsyncTest("should activate a charge")
    @IgnoreTest("Cannot be tested with a private app.")
    public async Test4() { }
}
github nozzlegear / Shopify-Prime / tests / discounts.ts View on Github external
TestFixture,
    Timeout
    } from 'alsatian';
import { Config, Expect } from './test_utils';

@TestFixture("Discount Tests")
export class DiscountTests {
    @AsyncTest("should create a Discount")
    @IgnoreTest("cannot be tested without a Shopify Plus account.")
    public async Test1() { }

    @AsyncTest("should get a Discount")
    @IgnoreTest("cannot be tested without a Shopify Plus account.")
    public async Test2() { }

    @AsyncTest("should list Discounts,")
    @IgnoreTest("annot be tested without a Shopify Plus account.")
    public async Test3() { }

    @AsyncTest("should delete a Discount")
    @IgnoreTest("cannot be tested without a Shopify Plus account.")
    public async Test4() { }

    @AsyncTest("should enable a Discount")
    @IgnoreTest("cannot be tested without a Shopify Plus account.")
    public async Test5() { }

    @AsyncTest("should disable a Discount")
    @IgnoreTest("cannot be tested without a Shopify Plus account.")
    public async Test6() { }
}

alsatian

TypeScript and JavaScript testing framework for beautiful and readable tests

MIT
Latest version published 4 years ago

Package Health Score

47 / 100
Full package analysis