@angular-package/testing
TypeScript icon, indicating that this package has built-in type declarations

2.0.0-rc • Public • Published

Packages

Package Description Status
callback Manages the callback function. npm version
change-detection Improves application performance. npm version
component-loader Handles dynamic loading components. npm version
core Core features. npm version
error Manages an Error. npm version
name The name with prefix and suffix. npm version
preferences Preferences, settings, options, configuration and setup in steps. npm version
prism Prism highlighter module. npm version
property Handles object properties. npm version
range The range between a minimum and maximum. npm version
reactive Automatize the process of creating some rxjs features. npm version
storage The storage of data under allowed names. npm version
tag Any tag with optional attributes. npm version
testing Support for testing other packages. npm version
text Text on the template with replaceable tags. npm version
type Common types, type guards, and type checkers. npm version
ui User interface. In Progress
wrapper Wrap the text with the opening and closing chars. npm version

Click on the package name to visit its GitHub page.


angular-package/testing

Support for testing other packages.

Gitter Discord Twitter

npm version

GitHub issues GitHub forks GitHub stars GitHub license

GitHub sponsors Support me on Patreon


Table of contents


Basic concepts

Checks

It's to check the provided value to be the same as expected.

Type guard (constrain)

Constrains the parameter type to not let input unexpected value in the code editor.

Guards

It's a combination of both above, constrains the type of the parameter in the code editor, and checks its provided argument.

Defines

Returns defined value from a method of an object.
Defines new value in an object and returns a defined value.

Gets

Returns a value from an object.

Sets

Adds or updates an element with a specified key and a value to an object and returns an object.


Skeleton

This package was built by the library skeleton which was generated with Angular CLI version 12.2.5.

Copy this package to the packages/testing folder of the library skeleton then run the commands below.

Build

Run ng build testing to build the package. The build artifacts will be stored in the dist/ directory.

Running unit tests

Run ng test testing to execute the unit tests via Karma.


Installation

Install @angular-package/testing package with command:

npm i --save @angular-package/testing

Api

// Main.
import {
  // Class.
  Testing,
  TestingToBeMatchers,
} from '@angular-package/testing';
// Helper functions.
import {
  // Function.
  randomNumber,
  randomString,
} from '@angular-package/testing';
// Helper constants.
import {
  // Example class for testing.
  TestingClass,
  TestingPerson,

  // Array.
  TESTING_ARRAY_BIGINT,
  TESTING_ARRAY_BOOLEAN,
  TESTING_ARRAY_CLASS,
  TESTING_ARRAY_FUNCTION,
  TESTING_ARRAY_NULL,
  TESTING_ARRAY_NUMBER,
  TESTING_ARRAY_OBJECT_ONE,
  TESTING_ARRAY_STRING,
  TESTING_ARRAY_SYMBOL_NUMBER,
  TESTING_ARRAY_SYMBOL_STRING,
  TESTING_ARRAY_UNDEFINED,
  // BigInt
  TESTING_BIGINT,
  // Class.
  TESTING_CLASS,
  TESTING_PERSON,
  // Date.
  TESTING_DATE,
  // Boolean.
  TESTING_FALSE,
  TESTING_FALSE_INSTANCE,
  TESTING_TRUE,
  TESTING_TRUE_INSTANCE,
  // Function.
  TESTING_FUNCTION,
  TESTING_FUNCTION_CONSTRUCTOR,
  TESTING_FUNCTION_CONSTRUCTOR_PERSON,
  // null.
  TESTING_NULL,
  // Number.
  TESTING_NUMBER,
  TESTING_NUMBER_CONSTRUCTOR,
  TESTING_NUMBER_INSTANCE,
  // Object.
  TESTING_OBJECT,
  // RegExp.
  TESTING_REGEXP,
  // String.
  TESTING_STRING,
  TESTING_STRING_CONSTRUCTOR,
  TESTING_STRING_INSTANCE,
  // Symbol.
  TESTING_SYMBOL_NUMBER,
  TESTING_SYMBOL_STRING,
  // Undefined.
  TESTING_UNDEFINED,
} from '@angular-package/testing';
import {
  // Interface. 
  TestingObject,
  TestingPersonShape
} from '@angular-package/testing';

Instance of

Possible names of javascript objects that can be checked by the instanceof operator.

const value: any = new Object({});
value instanceof Array
value instanceof ArrayBuffer;
value instanceof Boolean;
value instanceof DataView;
value instanceof Date;
value instanceof Error;
value instanceof EvalError;
value instanceof Int16Array;
value instanceof Int32Array;
value instanceof Int8Array;
value instanceof Map;
value instanceof Promise;
value instanceof RangeError
value instanceof RangeError;
value instanceof ReferenceError;
value instanceof RegExp;
value instanceof Set;
value instanceof SharedArrayBuffer;
value instanceof SyntaxError;
value instanceof Float32Array;
value instanceof Float64Array;
value instanceof Function;
value instanceof Number;
value instanceof Object;
value instanceof String;
value instanceof Storage;
value instanceof TypeError;
value instanceof Uint16Array;
value instanceof Uint32Array;
value instanceof Uint8Array;
value instanceof Uint8ClampedArray;
value instanceof URIError;
value instanceof WeakMap;
value instanceof WeakSet;

Testing

Testing

Simple class to support testing.

Methods prefixed with the toBe aren't working with the beforeEach() function of jasmine.

Static methods:

Testing. Description
defineDescribe() Defines the wrapper function of the describe() function of jasmine with the ability to decide its execution.
defineIt() Defines the wrapper function of the it() function of jasmine with the ability to decide its execution.

Constructor:

Testing Description
constructor Creates an instance with setting for global allow executing of the describe() and it() methods, and optionally sets the list of allowed executable tests (those that execute even on the disallowed state).

Instance public methods:

Testing.prototype. Description
describe() Executes defined describe() function of jasmine on a state true from the execute.
it() Executes defined it() function of jasmine on a state true from the execute.
Testing.prototype. Executes the spec on a state true from the execute expecting the provided value to
toBe() be the given expected value.
toBeBigInt() be a bigint type on the given expected state of true.
toBeBooleanType() be of a boolean type on the given expected state of true.
toBeClass() be a class on the given expected state of true.
toBeInstanceOfArray() be an instance of an Array on the given expected state of true.
toBeInstanceOfBoolean() be an instance of Boolean on the given expected state of true.
toBeInstanceOfDate() be an instance of Date on the given expected state of true.
toBeInstanceOfError() be an instance of an Error on the given expected state of true.
toBeInstanceOfFunction() be an instance of a Function on the given expected state of true.
toBeInstanceOfMap() be an instance of a Map on the given expected state of true.
toBeInstanceOfNumber() be an instance of a Number on the given expected state of true.
toBeInstanceOfObject() be an instance of an Object on the given expected state of true.
toBeInstanceOfPromise() be an instance of Promise on the given expected state of true.
toBeInstanceOfRangeError() be an instance of RangeError on the given expected state of true.
toBeInstanceOfReferenceError() be an instance of ReferenceError on the given expected state of true.
toBeInstanceOfRegExp() be an instance of RegExp on the given expected state of true.
toBeInstanceOfSet() be an instance of Set on the given expected state of true.
toBeInstanceOfStorage() be an instance of Storage on the given expected state of true.
toBeInstanceOfString() be an instance of a String on the given expected state of true.
toBeInstanceOfSyntaxError() be an instance of SyntaxError on the given expected state of true.
toBeInstanceOfTypeError() be an instance of TypeError on the given expected state of true.
toBeInstanceOfURIError() be an instance of URIError on the given expected state of true.
toBeInstanceOfWeakSet() be an instance of a WeakSet on the given expected state of true.
toBeNull() be null on the given expected state of true.
toBeNumberType() be of a number type on the given expected state of true.
toBeStringType() be of a string type on the given expected state of true.
toEqual() be equal to the given expected.

Testing static methods

Testing.defineDescribe()

Defines the wrapper function of the describe() function of jasmine with the ability to decide its execution.

static defineDescribe(
  description: string,
  specDefinitions: () => void
): (execute: boolean) => void {
  return TestingDescribe.define(description, specDefinitions);
}

Parameters:

Name: type Description
description: string "Textual description of the group" - jasmine.
specDefinitions: () => void "Function for Jasmine to invoke that will define" - jasmine.

Returns:

The return value is a function that contains the describe() function of jasmine with the ability to decide its execution.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * Tests.
 */
const testingDescribe = Testing.defineDescribe('Primitives values', () => {
  const numberSpec = Testing.defineIt('The value must be a number type', () => {
    expect(is.number(5)).toBeTruthy();
  }, 3000);
  numberSpec(false); // Do not execute.
  numberSpec(true); // Execute.
});

testingDescribe(false); // Do not execute.
testingDescribe(true); // Execute.

Testing.defineIt()

Defines the wrapper function of the it() function of jasmine with the ability to decide its execution.

static defineIt(
  expectation: string,
  assertion: jasmine.ImplementationCallback,
  timeout?: number | undefined,
): (execute: boolean) => void {
  return TestingIt.define(expectation, assertion, timeout);
}

Parameters:

Name: type Description
description: string "Textual description of the group" - jasmine.
specDefinitions: () => void "Function for Jasmine to invoke that will define" - jasmine.

Returns:

The return value is a function that contains the describe() function of jasmine with the ability to decide its execution.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * defineIt().
 */
testing.describe('defineIt()', () => {
  const numberSpec = Testing.defineIt('The value must be a number type', () => {
    expect(is.number(5)).toBeTruthy();
  }, 3000);
  numberSpec(false); // Do not execute.
  numberSpec(true); // Execute.
});


Testing constructor

Creates an instance with setting for global allow executing of the describe() and it() methods, and optionally sets the list of allowed executable tests (those that execute even on the disallowed state).

constructor(
  allowDescribe: boolean,
  allowIt: boolean,
  executable?: ExecutableTests
) {
  super(allowDescribe, allowIt, executable);
}

Parameters:

Name: type Description
allowDescribe: boolean Allow executing describe() methods.
allowIt: boolean Allow executing it() methods.
executable?: ExecutableTests An optional object with unique numbers of executable tests for describe() and it() method.

Returns:

The return value is new instance of a Testing.

Usage:

// Example usage.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(
  true, // Allows executing the `describe()` method globally.
  true, // Allows executing the `it()` method globally.
  {
    describe: [], // Executable unique numbers of `describe()` methods to execute when global executing is disallowed.
    it: [], // Executable unique numbers of `it()` methods to execute when global executing is disallowed.
  }
);

Example of using allow.

/**
 * Initialize testing.
 */
const testing = new Testing(
  false, // Disallows executing the `describe()` method globally.
  false, // Disallows executing the `it()` method globally.
  {
    describe: [1, 2, 3, 5], // Executable unique numbers of `describe()` methods to execute when global executing is disallowed.
    it: [1], // Executable unique numbers of `it()` methods inside the `describe()` to execute when global executing is disallowed.
  }
);

testing.describe('[counter] First describe', () => {
  testing
    .it('[counter] First it() in first describe 1-1', () =>
      expect(false).toBeFalse()
    )
    .it('[counter] Second it() in first describe 1-2', () =>
      expect(true).toBeTrue()
    )
    .it('[counter] Second it() in first describe 1-3', () =>
      expect(true).toBeTrue()
    )
    .it('[counter] Fourth it() in first describe() 1-4', () =>
      expect(true).toBeTrue()
    )
    .describe('[counter] Second describe()', () => {
      testing.it('[counter] First it() in second describe() 2-1', () =>
        expect(true).toBeTrue()
      );
    })
    .describe('[counter] Third describe()', () => {
      testing.it('[counter] First it() in third describe() 3-1', () =>
        expect(true).toBeTrue()
      );
    })
    .describe('[counter] Fourth describe()', () => {
      testing.it('[counter] First it() in fourth describe() 3-1', () =>
        expect(true).toBeTrue()
      );
    });
});
testing.describe('[counter] Fifth describe', () =>
  testing.it('[counter] First it() in fifth describe 5-1', () =>
    expect(false).toBeFalse()
  )
);
/*
  Karma returns
  1 First describe
      1 First it() in first describe 1-1
    3 Third describe()
      1 First it() in third describe() 3-1
    2 Second describe()
      1 First it() in second describe() 2-1
  5 Fifth describe
    1 First it() in fifth describe 5-1 
*/

Testing instance methods

Testing.prototype.describe()

Executes defined describe() function of jasmine on provided state true from the execute, and resets the counter to 0.

public describe(
  description: string,
  specDefinitions: () => void,
  execute?: boolean
): this {
  this.#testingIt.resetCounter();
  this.#testingDescribe.describe(description, specDefinitions, execute);
  return this;
}

Parameters:

Name: type Description
description: string "Textual description of the group" with an optional its unique number inside the describe when adding [counter].
specDefinitions: () => void "Function for Jasmine to invoke that will define inner suites a specs".
execute: boolean A boolean type value to decide whether or not execute defined describe() of jasmine function.

Returns:

The return value is an instance of Testing.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * describe().
 */
testing.describe(
  '[counter] describe()',
  () => {},
  true // Whether or not execute suite
);

Testing.prototype.it()

Executes defined it() function of jasmine on provided state true from the execute.

public it(
  expectation: string,
  assertion: jasmine.ImplementationCallback,
  execute?: boolean
): this {
  this.#testingIt.it(expectation, assertion, execute);
  return this;
}

Parameters:

Name: type Description
description: string "Textual description of what this spec is checking" with an optional its unique number when adding [counter].
specDefinitions: () => void "Function that contains the code of your test. If not provided the test will be pending.".
execute: boolean A boolean type value to decide whether or not execute defined it() of jasmine function.

Returns:

The return value is an instance of Testing.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * it().
 */
testing.describe(
  '[counter] describe()',
  () => testing.it('[counter] it()', () => {
      expect(true).toBeTruthy();
    },
    true // Whether or not execute spec.
  ),
  true // Whether or not execute suite.
);

Testing.prototype.toBe()

update

Executes the spec on a state true from the execute expecting the provided value to be the given expected value. The execute parameter is optional because, by default it takes its value from the global allowIt parameter specified in the constructor.

public toBe<Value>(
  expectation: string,
  value: Value,
  expected: any,
  execute?: boolean
): this {
  this.it(expectation, () => expect(value).toBe(expected), execute);
  return this;
}

Parameters:

Name: type Description
expectation: string "Textual description of what this spec is checking" with an optional its unique number when adding [counter].
value: Value The value of any type passed to the expect() function of jasmine.
expected: any The value of any type passed to the toBe() method of jasmine.Matchers.
execute?: boolean An optional parameter that specifies whether the spec is to be executed. By default it takes its value from the global allowIt parameter specified in the constructor.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(
  true,
  false // Execute `it()` method globally is off.
);
/**
 * toBe().
 */
testing.describe('string', () => {
  testing.toBe(
    `Checks the value against the string`,
    is.stringType('my name'),
    true,
    true  // Even if globally executing the method `it()` is off, `execute` parameter as `true` executes this spec.
  );
});

Testing.prototype.toBeBigInt()

update

Executes the spec on a state true from the execute expecting the provided value to be a bigint type on the expected of true. The method uses isBigInt() function of @angular-package/type.

public toBeBigInt<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be a \`bigint\` type`,
  expected: boolean = true
): this {
  this.toBe(expectation, is.bigint(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be a bigint type'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Object.
import { is } from '@angular-package/type';
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeBigInt().
 */
testing.describe('bigint', () => testing.toBeBigInt(1n));

Testing.prototype.toBeBooleanType()

update

Executes the spec on a state true from the execute expecting the provided value to be of a boolean type on the expected of true. The method uses isBooleanType() function of @angular-package/type.

public toBeBooleanType<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be of a \`boolean\` type`,
  expected: boolean = true
): this {
  this.toBe(expectation, is.booleanType(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be of a boolean type'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeBooleanType().
 */
testing.describe('boolean', () => testing.toBeBooleanType(false));

Testing.prototype.toBeClass()

Executes the spec on a state true from the execute expecting the provided value to be a class on the expected of true. The method uses isClass() function of @angular-package/type.

public toBeClass<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be a \`class\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.class(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be a class'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeClass().
 */
testing.describe('class Person', () => {
  class Person {}
  testing.toBeClass(Person);
});

Testing.prototype.toBeInstanceOfArray()

Executes the spec on a state true from the execute expecting the provided value to be an instance of an Array on the expected of true. The method uses isArray() function of @angular-package/type.

public toBeInstanceOfArray<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of an \`${Array.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.array(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of an Array'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfArray().
 */
testing.describe('Array', () => testing.toBeInstanceOfArray(['1']));

Testing.prototype.toBeInstanceOfBoolean()

Executes the spec on a state true from the execute expecting the provided value to be an instance of Boolean on the expected of true. The method uses isBooleanObject() function of @angular-package/type.

public toBeInstanceOfBoolean<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${Boolean.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.booleanObject(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of an Boolean'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfBoolean().
 */
testing.describe('Boolean', () => testing.toBeInstanceOfBoolean(new Boolean()));

Testing.prototype.toBeInstanceOfDate()

Executes the spec on a state true from the execute expecting the provided value to be an instance of Date on the expected of true. The method uses isDate() function of @angular-package/type.

public toBeInstanceOfDate<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${Date.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.date(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of Date'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfDate().
 */
testing.describe('Date', () => testing.toBeInstanceOfDate(new Date()));

Testing.prototype.toBeInstanceOfError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of an Error the expected of true.

public toBeInstanceOfError<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of an \`${Error.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof Error, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of an Error'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfError().
 */
testing.describe('Error', () => {
  try {
    throw new Error();
  } catch (e) {
    testing.toBeInstanceOfError(e);
  }
});

Testing.prototype.toBeInstanceOfFunction()

Executes the spec on a state true from the execute expecting the provided value to be an instance of a Function on the expected of true.

public toBeInstanceOfFunction<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of a \`${Function.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof Function, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of a Function'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfFunction().
 */
testing.describe(`Function`, () => testing.toBeInstanceOfFunction(() => {}));

Testing.prototype.toBeInstanceOfMap()

Executes the spec on a state true from the execute expecting the provided value to be an instance of a Map on the expected of true.

public toBeInstanceOfMap<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of a \`${Map.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof Map, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of a Map'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfMap().
 */
testing.describe(`Map`, () => testing.toBeInstanceOfMap(new Map()));

Testing.prototype.toBeInstanceOfNumber()

Executes the spec on a state true from the execute expecting the provided value to be an instance of a Number on the expected of true. The method uses isNumberObject() function of @angular-package/type.

public toBeInstanceOfNumber<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of a \`${Number.name}\``,
  expected: boolean = true,
): this {
  this.toBe(expectation, is.numberObject(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of a Number'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * Tests.
 */
testing.describe(`Number`, () =>
  testing.toBeInstanceOfNumber(new Number(27))
);

Testing.prototype.toBeInstanceOfObject()

Executes the spec on a state true from the execute expecting the provided value to be an instance of an Object on the expected of true. The method uses isObject() function of @angular-package/type.

public toBeInstanceOfObject<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of an \`${Object.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.object(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of an Object'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfObject()
 */
testing.describe(`Object`, () =>
  testing
    .toBeInstanceOfObject(new Object({}))
    .toBeInstanceOfObject({})
);

Testing.prototype.toBeInstanceOfPromise()

Executes the spec on a state true from the execute expecting the provided value to be an instance of Promise on the expected of true.

public toBeInstanceOfPromise<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${Promise.name}\``,
  expected: boolean = true,
): this {
  this.toBe(expectation, value instanceof Promise, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of Promise'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfPromise()
 */
const myPromise = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve('foo');
    // reject('foo');
  }, 300);
});
testing.describe(`Promise`, () => testing.toBeInstanceOfPromise(myPromise));

Testing.prototype.toBeInstanceOfRangeError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of RangeError on the expected state.

public toBeInstanceOfRangeError<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${RangeError.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof RangeError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of RangeError'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfRangeError()
 */
testing.describe('RangeError', () => {
  try {
    throw new RangeError();
  } catch (e) {
    testing.toBeInstanceOfRangeError(e);
  }
});

Testing.prototype.toBeInstanceOfReferenceError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of ReferenceError on the expected of true.

public toBeInstanceOfReferenceError<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${ReferenceError.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof ReferenceError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of ReferenceError'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfRangeError()
 */
testing.describe('RangeError', () => {
  try {
    throw new RangeError();
  } catch (e) {
    testing.toBeInstanceOfRangeError(e);
  }
});

Testing.prototype.toBeInstanceOfRegExp()

Executes the spec on a state true from the execute expecting the provided value to be an instance of RegExp on the expected of true. The method uses isRegExp() function of @angular-package/type.

public toBeInstanceOfRegExp<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${RegExp.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.regexp(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of RegExp'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfRegExp()
 */
testing.describe(`RegExp`, () =>
  testing.toBeInstanceOfRegExp(new RegExp(/[]/g))
);

Testing.prototype.toBeInstanceOfSet()

Executes the spec on a state true from the execute expecting the provided value to be an instance of Set on the expected of true.

public toBeInstanceOfSet<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${Set.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof Set, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of Set'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfSet()
 */
testing.describe(`Promise`, () => testing.toBeInstanceOfSet(new Set()));

Testing.prototype.toBeInstanceOfStorage()

Executes the spec on a state true from the execute expecting the provided value to be an instance of Storage on the expected of true.

public toBeInstanceOfStorage<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${Storage.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof Storage, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of Storage'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfStorage()
 */
testing.describe(`Storage`, () => testing.toBeInstanceOfStorage(window.sessionStorage));

Testing.prototype.toBeInstanceOfString()

Executes the spec on a state true from the execute expecting the provided value to be an instance of a String on the expected of true. The method uses isStringObject() function of @angular-package/type.

public toBeInstanceOfString<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of a \`${String.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.stringObject(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of a String'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfString()
 */
testing.describe(`String`, () => testing.toBeInstanceOfString(new String()));

Testing.prototype.toBeInstanceOfSyntaxError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of SyntaxError on the expected of true.

public toBeInstanceOfSyntaxError<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${SyntaxError.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof SyntaxError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of SyntaxError'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfSyntaxError()
 */
testing.describe('SyntaxError', () => {
  try {
    throw new SyntaxError();
  } catch (e) {
    testing.toBeInstanceOfSyntaxError(e);
  }
});

Testing.prototype.toBeInstanceOfTypeError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of TypeError on the expected of true.

public toBeInstanceOfTypeError<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${TypeError.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof TypeError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of SyntaxError'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfTypeError()
 */
testing.describe('TypeError', () => {
  try {
    throw new TypeError();
  } catch (e) {
    testing.toBeInstanceOfTypeError(e);
  }
});

Testing.prototype.toBeInstanceOfURIError()

Executes the spec on a state true from the execute expecting the provided value to be an instance of URIError on the expected of true.

public toBeInstanceOfURIError<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of \`${URIError.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof URIError, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of URIError'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfURIError()
 */
testing.describe('URIError', () => {
  try {
    throw new URIError();
  } catch (e) {
    testing.toBeInstanceOfURIError(e);
  }
});

Testing.prototype.toBeInstanceOfWeakSet()

Executes the spec on a state true from the execute expecting the provided value to be an instance of a WeakSet on the expected of true.

public toBeInstanceOfWeakSet<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be an instance of a \`${WeakSet.name}\``,
  expected: boolean = true
): this {
  this.toBe(expectation, value instanceof WeakSet, expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be an instance of WeakSet'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeInstanceOfWeakSet()
 */
testing.describe(`WeakSet`, () => testing.toBeInstanceOfWeakSet(new WeakSet()));

Testing.prototype.toBeNull()

Executes the spec on a state true from the execute expecting the provided value to be null on the expected of true. The method uses isNull() function of @angular-package/type.

public toBeNull<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be \`null\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.null(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be null'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeNull()
 */
testing.describe(`null`, () => testing.toBeNull(null));

Testing.prototype.toBeNumberType()

Executes the spec on a state true from the execute expecting the provided value to be of a number type on the expected of true. The method uses isNumberType() function of @angular-package/type.

public toBeNull<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be \`null\``,
  expected: boolean = true
): this {
  this.toBe(expectation, is.null(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be of a number type'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeNumberType()
 */
testing.describe(`number`, () => testing.toBeNumberType(5));

Testing.prototype.toBeStringType()

Executes the spec on a state true from the execute expecting the provided value to be of a string type on the expected of true. The method uses isStringType() function from the @angular-package/type.

public toBeStringType<Value>(
  value: Value,
  execute?: boolean,
  expectation: string = `The value must be of a \`string\` type`,
  expected: boolean = true
): this {
  this.toBe(expectation, is.stringType(value), expected, execute);
  return this;
}

Parameters:

Name: type Description
value: Value The value of any type to check.
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.
expectation: string The message for the karma, which by default is set to 'The value must be of a string type'.
expected: boolean Expects the result of the expectation to be true or false, by default it's true.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toBeStringType()
 */
testing.describe(`string`, () => testing.toBeStringType('my name'));

Testing.prototype.toEqual()

Executes the spec on a state true from the execute expecting the provided value to equal to the given expected.

"Expect the actual value to be equal to the expected, using deep equality comparison."

public toEqual<Value>(
  expectation: string,
  value: Value,
  expected: any,
  execute?: boolean
): this {
  this.it(expectation, () => expect(value).toEqual(expected), execute);
  return this;
}

Parameters:

Name: type Description
expectation: string "Textual description of what this spec is checking" with an optional its unique number when adding [counter].
value: Value The value of any type passed to the expect() function of jasmine.
expected: any The value of any type passed to the toEqual() method of jasmine.Matchers. "The expected value to compare against."
execute?: boolean An optional parameter that specifies whether the spec is to be executed, by default it takes its value from the global allowIt parameter specified in the constructor.

Returns:

The return value is an instance of a Testing.

Usage:

// Example usage.
// Class.
import { Testing } from '@angular-package/testing';
/**
 * Initialize testing.
 */
const testing = new Testing(true, true);
/**
 * toEqual()
 */
const firstName = 'My name';
testing.describe(`toEqual`, () => testing.toEqual('Expects `firstName` to equal to `My name`', firstName, 'My name'));

TestingToBeMatchers

Matchers that use the toBe() method of jasmine.Matchers.

Instance public methods:

TestingToBeMatchers.prototype. Expects provided value to be
array() an array.
bigint() a bigint type.
boolean() a boolean type or an instance of Boolean.
class() a class.
date() a Date.
defined() defined.
false() a boolean type or an instance of Boolean equal to false.
function() function.
instance() an instance of a class from the given constructor.
key() a property key.
null() null.
number() a number type or an instance of a Number.
numberBetween() a number type or an instance of a Number between the range of minimum and maximum.
object() an object.
objectKey() an object with a given key by using the hasOwnProperty() method of the Object.
objectKeyIn() an object with a given key in it(or its prototype chain) by using the in operator.
objectKeys() an object with given keys by using the hasOwnProperty() method of the Object.
objectKeysIn() an object with given keys in it(or its prototype chain) by using the in operator.
objectSomeKeys() an object with some of its keys or some groups of its keys of the PropertyKey type.
regexp() RegExp.
string() a string type or an instance of a String.
stringIncludes() a string type or an instance of a String that includes the specified words/sentences.
stringIncludesSome() a string type or an instance of a String that includes some of the specified words/sentences.
stringOfLength() a string type or an instance of a String of the specified length.
stringOfLengthBetween() a string type or an instance of a String of the length between the given minimum and maximum.
symbol() a symbol.
true() a boolean type or an instance of Boolean equal to true.
undefined() undefined.

TestingToBeMatchers.prototype.array()

Expects provided value to be an array. The method uses isArray() function from the @angular-package/type.

public array(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`array\``
): this {
  this.toBe(is.array(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the array and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an array.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let testArray: any;
  beforeEach(() => (testArray = [1, 'two', 3]));

  testing.describe('to be or not', () => {
    testing.it('an array', () =>
      toBe.array(testArray).
      not.array(2));
  });
});

TestingToBeMatchers.prototype.bigint()

Expects provided value to be a bigint type. The method uses isBigInt() function from the @angular-package/type.

public bigint(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`bigint\``
): this {
  this.toBe(is.bigint(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against bigint and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) bigint.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isBigint: any;
  beforeEach(() => (isBigint = 12n));
  testing.describe('to be or not', () => {
    testing.it('bigint', () =>
      toBe.bigint(isBigint).
      not.bigint(2));
  });
});

TestingToBeMatchers.prototype.boolean()

update

Expects provided value to be a boolean type or an instance of Boolean. The method uses isBoolean() function from the @angular-package/type.

public boolean(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`boolean\` type or an instance of \`Boolean\``
): this {
  this.toBe(is.boolean(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a boolean type or an instance of Boolean and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a boolean type or an instance of Boolean.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isBoolean: any;
  beforeEach(() => (isBoolean = false));

  testing.describe('to be or not to be the type of', () => {
    testing.it('boolean', () => toBe.boolean(isBoolean).not.boolean(3));
  });
});

TestingToBeMatchers.prototype.class()

Expects provided value to be class. The method uses isClass() function from the @angular-package/type.

public class(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`class\``
): this {
  this.toBe(is.class(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against class and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) class.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isClass: any;
  beforeEach(() => (isClass = class TestingClass {}));
  testing.describe('to be or not to be', () => {
    testing.it('class', () =>
      toBe.class(isClass).
      not.class('TestingClass'));
  });
});

TestingToBeMatchers.prototype.date()

Expects provided value to be a date. The method uses isDate() function from the @angular-package/type.

public date(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`date\``
): this {
  this.toBe(is.date(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against date and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a date.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isDate: any;
  beforeEach(() => (isDate = new Date()));
  testing.describe('to be or not to be the type of', () => {
    testing.it('date', () =>
      toBe.date(isDate).
      not.date(false));
  });
});

TestingToBeMatchers.prototype.defined()

update

Expects provided value to be defined. The method uses isDefined() function from the @angular-package/type.

public defined(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be defined`
): this {
  this.toBe(is.defined(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against defined and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) defined.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isDefined: any;
  testing.describe('to be or not to be', () => {
    testing.it('defined', () => toBe.defined('Defined').not.defined(isDefined));
  });
});

TestingToBeMatchers.prototype.false()

update

Expects provided value to be a boolean type or an instance of Boolean equal to false. The method uses isFalse() function from the @angular-package/type.

public false(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`boolean\` type or an instance of \`Boolean\` equal to \`false\``
): this {
  this.toBe(is.false(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a boolean type or an instance of Boolean equal to false and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a boolean type or an instance of Boolean equal to false.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isFalse: any;
  beforeEach(() => (isFalse = false));
  testing.describe('to be or not to be', () => {
    testing.it('`false`', () =>
      toBe.false(isFalse).not.false(true));
  });
});

TestingToBeMatchers.prototype.function()

Expects provided value to be function. The method uses isFunction() function from the @angular-package/type.

public function(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`function\``
): this {
  this.toBe(is.function(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against function and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) function.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isFunction: any;
  beforeEach(() => (isFunction = () => {}));
  testing.describe('to be or not to be', () => {
    testing.it('`function`', () => toBe.function(isFunction).not.function(true));
  });
});

TestingToBeMatchers.prototype.instance()

Expects provided value to be an instance of a class from the given constructor. The method uses isInstance() function from the @angular-package/type.

public instance<Type>(
  value: any,
  constructor: Constructor<Type>,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an instance of ${constructor.name}`
): this {
  this.toBe(is.instance(value, constructor), expected, expectationFailOutput);
  return this;
}

Generic type variables:

Name Description
Type A generic type variable by default of value captured from a given constructor.

Parameters:

Name: type Description
value: any The value of any type that is checked against an instance of a class from the given constructor and the result of its check is passed to the expect() function of jasmine.
constructor: Constructor<Type> A class or function that specifies the type of the constructor.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an instance of the given constructor.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers, TestingClass } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isInstance: any;
  beforeEach(() => isInstance = new TestingClass());
  testing.describe('to be or not to be', () => {
    testing.it(`an instance of \`TestingClass\``, () =>
      toBe.instance(isInstance, TestingClass).
      not.instance(isInstance, class Person {}));
  });
});

TestingToBeMatchers.prototype.key()

Expects provided value to be property key. The method uses isKey() function from the @angular-package/type.

public key(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be the property key`
): this {
  this.toBe(is.key(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the property key and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) property key.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isKey: any;
  beforeEach(() => (isKey = 'firstName'));
  testing.describe('to be or not to be', () => {
    testing.it('`key`', () => toBe.key(isKey).not.key(true));
  });
});

TestingToBeMatchers.prototype.null()

Expects provided value to be null. The method uses isNull() function from the @angular-package/type.

public null(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`null\``
): this {
  this.toBe(is.null(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against null and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) null.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isNull: any;
  beforeEach(() => (isNull = null));
  testing.describe('to be or not to be', () => {
    testing.it('`null`', () => toBe.null(isNull).not.null(undefined));
  });
});

TestingToBeMatchers.prototype.number()

update

Expects provided value to be a number type or an instance of a Number. The method uses isNumber() function from the @angular-package/type.

public number(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`number\` type or an instance of a \`Number\``
): this {
  this.toBe(is.number(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a number type or an instance of a Number and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a number type or an instance of a Number.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isNumber: any;
  beforeEach(() => (isNumber = 27));
  testing.describe('to be', () =>
    testing.it('`number`', () =>
      toBe.number(isNumber)))
  .describe('not to be', () =>
    testing.it('`number`', () =>
      toBe.not.number(undefined)));
});

TestingToBeMatchers.prototype.numberBetween()

update

Expects provided value to be a number type or an instance of a Number between the range of minimum and maximum. The method uses isNumberBetween() function from the @angular-package/type.

public numberBetween<Min extends number, Max extends number>(
  value: any,
  min: Min,
  max: Max,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`number\` type or an instance of a \`Number\` between the range of ${min} and ${max}`
): this {
  this.toBe(
    is.numberBetween(value, min, max),
    expected,
    expectationFailOutput
  );
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a number type or an instance of a Number within the specified range and the result of its check is passed to the expect() function of jasmine.
min: Min The minimum range of generic type variable Min of the given value.
max: Max The maximum range of generic type variable Max of the given value.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a number type or an instance of a Number between the range of minimum and maximum.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isNumberBetween: any;
  let min: any;
  let max: any;
  beforeEach(() => {
    isNumberBetween = 27;
    min = 26;
    max = 28;
  });

  testing.describe('to be', () =>
    testing.it(`\`number\` between 26 to 28`, () =>
      toBe.numberBetween(isNumberBetween, min, max)))
  .describe('not to be', () =>
    testing.it(`\`number\` between 26 to 28`, () =>
      toBe.not.numberBetween(127, min, max)));
});

TestingToBeMatchers.prototype.object()

Expects provided value to be an object. The method uses isObject() function from the @angular-package/type.

public object(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`object\``
): this {
  this.toBe(is.object(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against an object and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an object.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingClass, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let TESTING_CLASS: any;
  beforeEach(() => TESTING_CLASS = new TestingClass());
  testing.describe('to be or not to be', () => {
    testing.it(`an \`object\``, () =>
      toBe.object(TESTING_CLASS).
      not.object(undefined));
  });
});

TestingToBeMatchers.prototype.objectKey()

update

Expects provided value to be an object with a given key by using the hasOwnProperty() method of the Object. The method uses isObjectKey() function from the @angular-package/type.

public objectKey(
  value: any,
  key: PropertyKey,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`object\` with a given \`key\``
): this {
  this.toBe(is.objectKey(value, key), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against an object that contains a given key and the result of its check is passed to the expect() function of jasmine.
key: PropertyKey Property name of PropertyKey type of potential object from the provided value.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an object with a given key.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingClass, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let TESTING_CLASS: any;
  beforeEach(() => TESTING_CLASS = new TestingClass());
  testing.describe('to be or not to be', () => {
    testing.it(`an \`object\` with a given key`, () =>
      toBe.objectKey(TESTING_CLASS, 'firstName').
      not.objectKey(TESTING_CLASS, 'noFirstName'));
  });
});

TestingToBeMatchers.prototype.objectKeyIn()

update

Expects provided value to be an object with a given key in it(or its prototype chain) by using the in operator. The method uses isObjectKeyIn() function from the @angular-package/type.

public objectKeyIn(
  value: any,
  key: PropertyKey,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`object\` with a given \`key\` in it(or its prototype chain).`
): this {
  this.toBe(is.objectKeyIn(value, key), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against the object that contains a given key in it(or its prototype chain) and the result of its check is passed to the expect() function of jasmine.
key: PropertyKey Property name of PropertyKey type of potential object from the provided value.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an object with a given key in it(or its prototype chain).

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingClass, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let TESTING_CLASS: any;
  beforeEach(() => TESTING_CLASS = new TestingClass());
  testing.describe('to be or not to be', () =>
    testing.it(`an \`object\` with a given key in it(or its prototype chain)`, () =>
      toBe.objectKeyIn(TESTING_CLASS, 'firstName').
      not.objectKeyIn(TESTING_CLASS, 103040501)));
});

TestingToBeMatchers.prototype.objectKeys()

update

Expects provided value to be an object with given keys by using the hasOwnProperty() method of the Object. The method uses isObjectKeys() function from the @angular-package/type.

public objectKeys(
  value: any,
  keys: PropertyKey[],
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`object\` with given \`keys\``
): this {
  this.toBe(is.objectKeys(value, keys), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against an object that contains given keys and the result of its check is passed to the expect() function of jasmine.
keys: PropertyKey[] An array of property names of the PropertyKey type of potential object from the provided value.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an object with given keys.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingClass, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let TESTING_CLASS: any;
  beforeEach(() => TESTING_CLASS = new TestingClass());
  testing.describe('to be or not to be', () =>
    testing.it(`an \`object\` with some given keys`, () =>
      toBe.objectKeys(TESTING_CLASS, ['firstName', 'surname']).
      not.objectKeys(TESTING_CLASS, [10304050])));
});

TestingToBeMatchers.prototype.objectKeysIn()

new

Expects provided value to be an object with given keys in it(or its prototype chain) by using the in operator. The method uses isObjectKeysIn() function from the @angular-package/type.

public objectKeysIn(
  value: any,
  keys: PropertyKey[],
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`object\` with given \`keys\` in it(or its prototype chain)`
): this {
  this.toBe(is.objectKeysIn(value, keys), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against an object that contains given keys in it(or its prototype chain) and the result of its check is passed to the expect() function of jasmine.
keys: PropertyKey[] An array of property names of the PropertyKey type of potential object from the provided value.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an object with given keys in it(or its prototype chain).

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingClass, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let TESTING_CLASS: any;
  beforeEach(() => TESTING_CLASS = new TestingClass());
  testing.describe('to be or not to be', () =>
    testing.it(`an \`object\` with some given keys`, () =>
      toBe.objectKeysIn(TESTING_CLASS, ['firstName', 'surname', 10304050]).
      not.objectKeysIn(TESTING_CLASS, ['noFirstName'])));
});

TestingToBeMatchers.prototype.objectSomeKeys()

new

Expects provided value to be an object with some of its keys or some groups of its keys of the PropertyKey type. The method uses isObjectSomeKeys() function from the @angular-package/type.

public objectSomeKeys(
  value: any,
  keys: (PropertyKey | PropertyKey[])[],
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be an \`object\` with some of its keys or some groups of its keys from given \`keys\``
): this {
  this.toBe(is.objectSomeKeys(value, keys), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type to check against an object that contains some of its keys or some groups of its keys from given keys and the result of its check is passed to the expect() function of jasmine.
keys: (PropertyKey | PropertyKey[])[] An array of property names or a two-dimensional array of property names to check if the given value contains some of them or some groups of them.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) an object with some of its keys or some groups of its keys from given keys.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingClass, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let TESTING_CLASS: any;
  beforeEach(() => TESTING_CLASS = new TestingClass());
  testing.describe('to be or not to be', () =>
    testing.it(`an \`object\` with some given keys`, () =>
      toBe.objectSomeKeys(TESTING_CLASS, ['firstName', 'surname', [1030405027, 5]]).
      not.objectSomeKeys(TESTING_CLASS, [10304050, ['firstName', 10304050]])));
});

TestingToBeMatchers.prototype.regexp()

update

Expects provided value to be RegExp. The method uses isRegExp() function from the @angular-package/type.

public regexp(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`regexp\``
): this {
  this.toBe(is.regexp(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against RegExp and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) RegExp.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let regexp: any;
  beforeEach(() => regexp = /[]/g);
  testing.describe('to be or not to be', () =>
    testing.it(`\`RegExp\``, () =>
      toBe.regexp(regexp).not.regexp(undefined)));
});

TestingToBeMatchers.prototype.string()

update

Expects provided value to be a string type or an instance of a String. The method uses isString() function from the @angular-package/type.

public string(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`string\` type or an instance of a \`String\``
): this {
  this.toBe(is.string(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a string type or an instance of a String and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a string type or an instance of a String.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let string: any;
  beforeEach(() => string = 'My new string');
  testing.describe('to be or not to be', () => {
    testing.it(`\`string\``, () => toBe.string(string).not.string(undefined));
  });
});

TestingToBeMatchers.prototype.stringIncludes()

new

Expects provided value to be a string type or an instance of a String that includes the specified words/sentences. The method uses isStringIncludes() function from the @angular-package/type.

public stringIncludes(
  value: any,
  includes: string[],
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`string\` type or an instance of \`String\` that includes the specified words/sentences from a given \`includes\``
): this {
  this.toBe(
    is.stringIncludes(value, includes),
    expected,
    expectationFailOutput
  );
  return this;
}

Parameters:

Name: type Description
value: any The value of any type to check against a string type or an instance of a String that contains words/sentences from a given includes and the result of its check is passed to the expect() function of jasmine.
includes: string[] An Array of strings as words/sentences to be case-sensitive searched for within the given value.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a string type or an instance of a String that includes the specified words/sentences from a given includes.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let string: any;
  beforeEach(() => string = `Lorem Ipsum is simply dummy text of the printing and typesetting industry.
  Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
  when an unknown printer took a galley of type and scrambled it to make a type specimen book.
  It has survived not only five centuries, but also the leap into electronic typesetting,
  remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
  sheets containing Lorem Ipsum passages, and more recently with desktop publishing software
  like Aldus PageMaker including versions of Lorem Ipsum.` as string);
  testing.describe('to be or not to be', () => {
    testing.it(`\`string\``, () =>
      toBe.stringIncludes(string, ['Lorem', 'galley', 'It was popularised in the 1960s'])
      .not.stringIncludes(null, ['Lorem', 'galley', 'It was popularised in the 1960s'])
      .not.stringIncludes(string, ['Lorem', 'galley1', 'It was popularised in the 1960s'])
    );
  });
});

TestingToBeMatchers.prototype.stringIncludesSome()

new

Expects provided value to be a string type or an instance of a String that includes some of the specified words/sentences. The method uses isStringIncludesSome() function from the @angular-package/type.

public stringIncludesSome(
  value: any,
  includes: string[],
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`string\` type or an instance of \`String\` that includes some of the specified words/sentences from a given \`includes\``
): this {
  this.toBe(
    is.stringIncludesSome(value, includes),
    expected,
    expectationFailOutput
  );
  return this;
}

Parameters:

Name: type Description
value: any The value of any type to check against a string type or an instance of a String that contains some of the words/sentences from a given includes and the result of its check is passed to the expect() function of jasmine.
includes: string[] An Array of strings as words/sentences to be case-sensitive searched for within the given value.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a string type or an instance of a String that includes some of the specified words/sentences from a given includes.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let string: any;
  beforeEach(() => string = `Lorem Ipsum is simply dummy text of the printing and typesetting industry.
  Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
  when an unknown printer took a galley of type and scrambled it to make a type specimen book.
  It has survived not only five centuries, but also the leap into electronic typesetting,
  remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
  sheets containing Lorem Ipsum passages, and more recently with desktop publishing software
  like Aldus PageMaker including versions of Lorem Ipsum.` as string);
  testing.describe('to be or not to be', () => {
    testing.it(`\`string\``, () =>
      toBe.stringIncludesSome(string, ['Lorem', 'galley', 'It was popularised in the 1960s'])
      .not.stringIncludesSome(null, ['Lorem', 'galley', 'It was popularised in the 1960s'])
      .not.stringIncludesSome(string, ['Lorem1', 'galley1', 'It was popularised in the 1960s1'])
    );
  });
});

TestingToBeMatchers.prototype.stringOfLength()

update

Expects provided value to be a string type or an instance of a String of the given length. The method uses isStringLength() function from the @angular-package/type.

public stringOfLength<Length extends number>(
  value: any,
  length: Length,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`string\` type or an instance of a \`String\` of the specified \`length\` equal to ${length}`
): this {
  this.toBe(is.stringLength(value, length), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a string type or an instance of a String of the given length and the result of its check is passed to the expect() function of jasmine.
length: Length The length of generic type variable Length for the given value,
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a string type or an instance of a String of the specified length.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let string: any;
  let length: any;
  beforeEach(() => {
    string = 'My new string, My new string';
    length = 28;
  });
  testing.describe('to be or not to be', () => {
    testing.it(`a \`string\` of the given length`, () =>
      toBe.stringOfLength(string, length).
      not.stringOfLength(undefined, length-10));
  });
});

TestingToBeMatchers.prototype.stringOfLengthBetween()

new

Expects provided value to be a string type or an instance of a String of the length between the given minimum and maximum. The method uses isStringLengthBetween() function from the @angular-package/type.

public stringOfLengthBetween<Min extends number, Max extends number>(
  value: any,
  min: Min,
  max: Max,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`string\` type or an instance of a \`String\` of the \`length\` between the given ${min} and ${max}`
): this {
  this.toBe(
    is.stringLengthBetween(value, min, max),
    expected,
    expectationFailOutput
  );
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a string type or an instance of a String of the given min and max and the result of its check is passed to the expect() function of jasmine.
min: Min The minimum length of generic type variable Min of a given value.
max: Max The maximum length of generic type variable Max of a given value.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a string type or an instance of a String of the length between the given minimum and maximum.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let string: any;
  let min: any;
  let max: any;
  beforeEach(() => {
    string = 'My new string, My new string';
    min = 26;
    max = 28;
  });
  testing.describe('to be or not to be', () => {
    testing.it(`a \`string\` between the given min and max.`, () =>
      toBe.stringOfLengthBetween(string, min, max).
      not.stringOfLengthBetween(undefined, min, max));
  });
});

TestingToBeMatchers.prototype.symbol()

Expects provided value to be symbol. The method uses isSymbol() function from the @angular-package/type.

public symbol(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`symbol\``
): this {
  this.toBe(is.symbol(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a symbol and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a symbol.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isSymbol: any;
  beforeEach(() => isSymbol = Symbol('firstName'));
  testing.describe('to be or not to be', () => 
    testing.it(`a \`symbol\``, () => toBe.symbol(isSymbol).not.symbol(undefined)));
});

TestingToBeMatchers.prototype.true()

update

Expects provided value to be a boolean type or an instance of Boolean equal to true. The method uses isTrue() function from the @angular-package/type.

public true(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be a \`boolean\` type or an instance of \`Boolean\` equal to \`true\``
): this {
  this.toBe(is.true(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against a boolean type or an instance of Boolean equal to true and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) a boolean type or an instance of Boolean equal to true.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isTrue: any;
  beforeEach(() => isTrue = true);
  testing.describe('to be or not to be', () =>
    testing.it(`\`true\``, () => toBe.true(isTrue).not.true(false)));
});

TestingToBeMatchers.prototype.undefined()

Expects provided value to be undefined. The method uses isUndefined() function from the @angular-package/type.

public undefined(
  value: any,
  expected: jasmine.Expected<boolean> = true,
  expectationFailOutput: any = `${this.expectationFailOutput} ${
    this.getNot() === true ? `not` : ``
  } be \`undefined\``
): this {
  this.toBe(is.undefined(value), expected, expectationFailOutput);
  return this;
}

Parameters:

Name: type Description
value: any The value of any type that is checked against undefined and the result of its check is passed to the expect() function of jasmine.
expected: jasmine.Expected<boolean> The expected value of a boolean to compare against the result of the value check that is passed to the toBe() method of jasmine.Matchers.
expectationFailOutput: any An additional message when the matcher fails, by default, states the value should be (or not) undefined.

Returns:

The return value is an instance of a TestingToBeMatchers.

Usage:

// Example usage.
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
/**
 * Create `Testing` instance.
 */
const testing = new Testing(true, true);
const toBe = new TestingToBeMatchers();
/**
 * Tests.
 */
testing.describe('Expects provided value', () => {
  let isUndefined: any;
  beforeEach(() => isUndefined = undefined);
  testing.describe('to be or not to be', () => 
    testing.it(`\`undefined\``, () => toBe.undefined(isUndefined).not.undefined(null)));
});

Helpers

Functions

randomNumber()

The function generates a random number between 0 and declared max.

const randomNumber = <Max extends number>(
  max: Max
): NumberBetween<0, Max> => Math.floor(Math.random() * max);

Generic type variables:

Name Default value Description
Max Captured from the max A generic type variable Max indicates the maximum value of generic type NumberBetween via the return type NumberBetween<0, Max>.

Parameters:

Name: type Description
max: Max The maximum value of a generated number.

Returns:

The return value is a random number.

Usage:

// Example usage.
import { randomNumber } from '@angular-package/testing';

// Returns a randomly generated maximum number equal to 27 of type `NumberBetween<0, 27, number>`.
randomNumber(27);

randomString()

The function generates a random string of declared length.

const randomString = <Length extends number>(
  length: Length,
  chars = '0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ'
): StringOfLength<0, Length>  => {
  let randomStringOfLength = '';
  for (let i = 0; i <= length; i++) {
    const randomNumber = Math.floor(Math.random() * chars.length);
    randomStringOfLength += chars.substring(randomNumber, randomNumber + 1);
  }
  return randomStringOfLength.slice(0, -1);
};

Generic type variables:

Name Default value Description
Length Captured from the length A generic type variable Length indicates the maximum length of generic type StringOfLength via the return type StringOfLength<0, Length>.

Parameters:

Name: type Description
length: Length The maximum length of the generated random string.
chars: string The chars to generate a random string.

Returns:

The return value is a random string of declared length.

Usage:

// Example usage.
import { randomString } from '@angular-package/testing';

// Returns a randomly generated string of maximum length equal to 27 of type `StringOfLength<0, 27, string>`.
randomString(27);

Constants

Constants prepared for testing purposes.

Array

/**
 * An `Array` of `bigint`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_BIGINT = [
  TESTING_BIGINT,
  TESTING_BIGINT_CONSTRUCTOR,
  9007199254740991n,
];

/**
 * An `Array` of `boolean`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_BOOLEAN = [
  true,
  false,
  TESTING_TRUE_INSTANCE,
  TESTING_FALSE_INSTANCE,
  false,
  TESTING_FALSE,
  TESTING_TRUE,
];

/**
 * An `Array` of `class`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_CLASS = [
  new TestingClass(),
  new TestingClass(),
];

/**
 * An `Array` of `function`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_FUNCTION = [
  TESTING_FUNCTION,
  TESTING_FUNCTION_CONSTRUCTOR,
  TESTING_FUNCTION_CONSTRUCTOR_PERSON,
  (x: number, y: string): any => x,
];

/**
 * An `Array` of `null`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_NULL = [
  null,
  null,
  null,
  TESTING_NULL,
  TESTING_NULL,
];

/**
 * An `Array` of `number`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_NUMBER = [
  1,
  2,
  3,
  4,
  7,
  10,
  1000,
  3000,
  151233,
  TESTING_NUMBER,
  TESTING_NUMBER_CONSTRUCTOR,
  TESTING_NUMBER_INSTANCE,
];

/**
 * An `Array` of `object`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_OBJECT_ONE: Array<TestingObjectOne> = [
  { [TESTING_NUMBER]: 'my number', x: 3000 },
  { [TESTING_NUMBER]: 'my number', x: 1 },
];

/**
 * An `Array` of `string`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_STRING = [
  TESTING_STRING,
  TESTING_STRING_CONSTRUCTOR,
  TESTING_STRING_INSTANCE,
  '!@#$%^&*()Company',
];

/**
 * An `Array` of `symbol`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_SYMBOL_NUMBER = [
  TESTING_SYMBOL_NUMBER,
  Symbol(1005),
  Symbol(1002),
  Symbol(15),
  Symbol(1),
];

/**
 * An `Array` of `symbol`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_SYMBOL_STRING = new Array([
  TESTING_SYMBOL_STRING,
  Symbol('String Symbol'),
  Symbol('String Symbol'),
  Symbol('String Symbol One'),
  Symbol('String Symbol Two'),
]);

/**
 * An `Array` of `undefined`.
 * Array: true
 * Object: true
 * typeOf(): "array"
 * typeof: "object"
 */
const TESTING_ARRAY_UNDEFINED: Array<undefined | unknown> = [
  undefined,
  undefined,
  undefined,
  TESTING_UNDEFINED,
  TESTING_NOT_DEFINED,
];

BigInt

/**
 * typeOf(): "bigint"
 * typeof: "bigint"
 */
const TESTING_BIGINT = BigInt('9007199254740991');

Boolean

/**
 * typeOf(): "boolean"
 * typeof: "boolean"
 */
const TESTING_FALSE = false;

/**
 * typeOf(): "boolean"
 * typeof: "boolean"
 */
const TESTING_TRUE = true;

/**
 * Boolean: true
 * Object: true
 * typeOf(): "boolean"
 * typeof: "object"
 */
// tslint:disable-next-line: ban-types no-construct
const TESTING_FALSE_INSTANCE = new Boolean(TESTING_FALSE);

/**
 * Boolean: true
 * Object: true
 * typeOf(): "boolean"
 * typeof: "object"
 */
// tslint:disable-next-line: ban-types no-construct
const TESTING_TRUE_INSTANCE = new Boolean(TESTING_TRUE);

Class

/**
 * Function: true
 * Object: true
 * class: true
 * typeOf(): "function"
 * typeof: "function"
 */
class TestingClass {

  /**
   * Property as `number` of a `string` type.
   */
  1030405027 = 'my new number';

  /**
   * Property as `number` of a `number` type.
   */
  5 = 27;

  /**
   * Property as `string` of a `string` type.
   */
  firstName = 'My name';

  /**
   * Property as `number` of a `string` type.
   */
  surname = 'Surname';

  /**
   * Property as `number` of a `number` type.
   */
  age = TESTING_NUMBER;

  /**
   * Property as `string` of a `string` type.
   */
  city = TESTING_STRING;

  /**
   * Getter as `number` of a `number` type.
   */
  get [TESTING_NUMBER](): number {
    return this.age;
  }

  /**
   * Getter as `string` of a `string` type.
   */
  get [TESTING_STRING](): string {
    return this.city;
  }

  /**
   * Getter as `symbol number` of a `number` type.
   */
  get [TESTING_SYMBOL_NUMBER](): number {
    return this.age;
  }

  /**
   * Getter as `symbol string` of a `string` type.
   */
  get [TESTING_SYMBOL_STRING](): string {
    return this.city;
  }
}

/**
 * Object: true
 * typeOf(): "object"
 * typeof: "object"
 */
const TESTING_CLASS = new TestingClass();

Date

/**
 * Date: true
 * Object: true
 * typeOf(): "date"
 * typeof: "object"
 */
const TESTING_DATE = new Date(1995, 11, 17, 3, 24, 0);

Function

/**
 * Function: true
 * Object: true
 * function: true
 * typeOf(): "function"
 * typeof: "function"
 */
const TESTING_FUNCTION = (x: number, y: string): any => x + y;

/**
 * Function: true
 * Object: true
 * function: true
 * typeOf(): "function"
 * typeof: "function"
 */
const TESTING_FUNCTION_CONSTRUCTOR = function(
  this: any,
  ...args: any[]
): any {
  if (args) {
    args.forEach((arg, index: number) => (this[index] = arg[index]));
  }
  return this;
};

/**
 * Function: true
 * Object: true
 * function: true
 * typeOf(): "function"
 * typeof: "function"
 */
const TESTING_FUNCTION_CONSTRUCTOR_PERSON = function(
  this: TestingPerson,
  ...args: any[]
): TestingPerson {
  if (args) {
    this.firstName = args[0];
    this.surname = args[1];
    this.age = args[2];
  }
  return this;
};

null

/**
 * typeOf(): "null"
 * typeof: "object"
 */
const TESTING_NULL = null;

Number

/**
 * typeOf(): "number"
 * typeof: "number"
 */
const TESTING_NUMBER = 10304050;

/**
 * typeOf(): "number"
 * typeof: "number"
 */
const TESTING_NUMBER_CONSTRUCTOR = Number(TESTING_NUMBER);

/**
 * Number: true
 * Object: true
 * typeOf(): "number"
 * typeof: "object"
 */
// tslint:disable-next-line: ban-types no-construct
const TESTING_NUMBER_INSTANCE: Number = new Number(
  TESTING_NUMBER
);

Object

/**
 * Object: true,
 * typeOf(): "object",
 * typeof: "object"
 */
const TESTING_OBJECT_ONE: TestingObjectOne = {
  'key as string': true,
  1030405027: 'key is number',
  5: 'key is also number',
  [TESTING_NUMBER]: 'key is number',
  [TESTING_STRING]: 'key is string',
  [TESTING_SYMBOL_NUMBER]: 'key is symbol number',
  [TESTING_SYMBOL_STRING]: 6,
  x: 3000,
};

/**
 * Object: true,
 * typeOf(): "object",
 * typeof: "object"
 */
const TESTING_OBJECT_ONE_NEW = new Object(TESTING_OBJECT_ONE);

RegExp

/**
 * RegExp: true,
 * Object: true,
 * typeOf(): "regexp",
 * typeof: "object"
 */
const TESTING_PATTERN = /[^a-zA-Z0-9]/g;

String

/**
 * typeOf(): "string"
 * typeof: "string"
 */
const TESTING_STRING = '!@#$%^&*()Company';

/**
 * typeOf(): "string"
 * typeof: "string"
 */
const TESTING_STRING_CONSTRUCTOR = String(TESTING_STRING);

/**
 * Object: true
 * String: true
 * typeOf(): "string"
 * typeof: "object"
 */
// tslint:disable-next-line: ban-types no-construct
const TESTING_STRING_INSTANCE = new String(
  TESTING_STRING
);

Symbol

/**
 * typeOf(): "symbol"
 * typeof: "symbol"
 */
const TESTING_SYMBOL_NUMBER: unique symbol = Symbol(
  TESTING_NUMBER
);

/**
 * typeOf(): "symbol"
 * typeof: "symbol"
 */
const TESTING_SYMBOL_STRING: unique symbol = Symbol(
  TESTING_STRING
);

undefined

/**
 * typeOf(): "undefined"
 * typeof: "undefined"
 */
const TESTING_UNDEFINED = undefined;

Changelog

The changelog of this package is based on keep a changelog. To read it, click on the CHANGELOG.md link.

A changelog is a file which contains a curated, chronologically ordered list of notable changes for each version of a project. - keep a changelog


GIT

Commit

Versioning

Semantic Versioning 2.0.0

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards-compatible manner, and
  • PATCH version when you make backwards-compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

FAQ How should I deal with revisions in the 0.y.z initial development phase?

The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.

How do I know when to release 1.0.0?

If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.

License

MIT © angular-package (license)

Dependents (0)

Package Sidebar

Install

npm i @angular-package/testing

Weekly Downloads

2

Version

2.0.0-rc

License

MIT

Unpacked Size

670 kB

Total Files

75

Last publish

Collaborators

  • sciborrudnicki
  • angularpackage