Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
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.
* 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)
import { Expect, TestCase, TestFixture } from "alsatian";
export class CaseArgumentTestsTests {
@TestCase(1, 2, 3)
@TestCase(1.5, 2.5, 4)
public AddNumbers(first: number, second: number, expected: number) {
Expect(first + second).toBe(expected);
}
@TestCase("Hello", " world!", "Hello world!")
@TestCase("Far", "away", "Faraway")
public AddStrings(first: number, second: number, expected: number) {
Expect(first + second).toBe(expected);
}
@TestCase({a: 1}, {a: 2}, 3)
public AddObjectProperty(first: {a: number}, second: {a: number}, expected: number) {
Expect(first.a + second.a).toBe(expected);
}
@TestCase([1, 2], [3, 4], 10)
public AddArray(first: Array, second: Array, expected: number) {
const reduced = [...first, ...second].reduce((agg, curr) => agg + curr, 0);
Expect(reduced).toBe(expected);
}
}
import { Expect, TestCase, TestFixture } from "alsatian";
export class CaseArgumentTestsTests {
@TestCase(1, 2, 3)
@TestCase(1.5, 2.5, 4)
public AddNumbers(first: number, second: number, expected: number) {
Expect(first + second).toBe(expected);
}
@TestCase("Hello", " world!", "Hello world!")
@TestCase("Far", "away", "Faraway")
public AddStrings(first: number, second: number, expected: number) {
Expect(first + second).toBe(expected);
}
@TestCase({a: 1}, {a: 2}, 3)
public AddObjectProperty(first: {a: number}, second: {a: number}, expected: number) {
Expect(first.a + second.a).toBe(expected);
}
@TestCase([1, 2], [3, 4], 10)