How to use the ava.test.serial function in ava

To help you get started, we’ve selected a few ava examples, based on popular ways it is used in public projects.

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

github TrueLayer / truelayer-client-javascript / test / integration / integration.spec.ts View on Github external
} else {
    test("No 'access_token' environment variable set. Integration test disabled.", (t) => t.pass());
}

const now = moment(new Date(Date.now())).startOf("hour");
const from = now.clone().subtract(2, "hours").toDate();
const to = now.clone().subtract(1, "hours").toDate();
const providers = ["hsbc", "oauth-monzo", "ob-barclays"];
const endpoints = ["accounts", "info"];

test.serial("Get /data/status returns success", async (t) => {
    t.plan(1);
    await t.notThrows(StatusAPIClient.getStatus(from, to, providers, endpoints));
});

test.serial("Get /data/status actually returns something", async (t) => {
    t.plan(1);
    const statuses = (await StatusAPIClient.getStatus(from, to, providers, endpoints)).results;
    const receivedProviders: string[] = [];
    for (const status of statuses) {
        status.providers.map((p) => receivedProviders.push(p.provider_id));
    }
    t.deepEqual(receivedProviders, providers);
});
github TrueLayer / truelayer-client-javascript / test / integration / integration.spec.ts View on Github external
const cards: TrueLayer.ICard[] = resp.results;
        const assertions: number = cards.length;
        t.plan(assertions);
        for (const card of cards) {
            await t.notThrows(DataAPIClient.getCardPendingTransactions(access_token, card.account_id));
        }
    });

    test.serial("Get /cards/{id}/transactions/pending returns error - invalid token", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getCardPendingTransactions("invalid_token", "invalid_account"));
        t.is(error.error, "invalid_access_token");
        t.is(error.message, "Invalid access token.");
    });

    test.serial("Get /cards/{id}/transactions/pending returns error - invalid account", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getCardPendingTransactions(access_token, "invalid_account"));
        t.is(error.error, "account_not_found");
        t.is(error.message, "account not found");
    });

} else {
    test("No 'access_token' environment variable set. Integration test disabled.", (t) => t.pass());
}

const now = moment(new Date(Date.now())).startOf("hour");
const from = now.clone().subtract(2, "hours").toDate();
const to = now.clone().subtract(1, "hours").toDate();
const providers = ["hsbc", "oauth-monzo", "ob-barclays"];
const endpoints = ["accounts", "info"];
github TrueLayer / truelayer-client-javascript / test / integration / integration.spec.ts View on Github external
t.is(error.error, "account_not_found");
        t.is(error.message, "account not found");
    });

    test.serial("Get /accounts/{id}/transactions/pending returns success for each account", async (t) => {
        const resp = await DataAPIClient.getAccounts(access_token);
        const accounts: TrueLayer.IAccount[] = resp.results;
        const assertions: number = accounts.length;
        t.plan(assertions);

        for (const account of accounts) {
            await t.notThrows(DataAPIClient.getPendingTransactions(access_token, account.account_id));
        }
    });

    test.serial("Get /accounts/{id}/transactions/pending returns error - invalid token", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getPendingTransactions("invalid_token", "invalid_account"));
        t.is(error.error, "invalid_access_token");
        t.is(error.message, "Invalid access token.");
    });

    test.serial("Get /accounts/{id}/transactions/pending returns error - invalid account", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getPendingTransactions(access_token, "invalid_account"));
        t.is(error.error, "account_not_found");
        t.is(error.message, "account not found");
    });

    test.serial("Get /accounts/{id}/balance returns success for each account", async (t) => {
        const resp = await DataAPIClient.getAccounts(access_token);
        const accounts: TrueLayer.IAccount[] = resp.results;
github TrueLayer / truelayer-client-javascript / test / integration / integration.spec.ts View on Github external
});

    test.serial("Get /accounts/{id}/balance returns error - invalid account", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getBalance(access_token, "invalid_account"));
        t.is(error.error, "account_not_found");
        t.is(error.message, "account not found");
    });

    /** cards **/
    test.serial("Get /cards returns success", async (t) => {
        t.plan(1);
        const response = await t.notThrows(DataAPIClient.getCards(access_token));
    });

    test.serial("Get /cards returns error - invalid token", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getCards("invalid_token"));
        t.is(error.error, "invalid_access_token");
        t.is(error.message, "Invalid access token.");
    });

    test.serial("Get /cards returns success for each result account", async (t) => {
        const resp = await DataAPIClient.getCards(access_token);
        const cards: TrueLayer.ICard[] = resp.results;
        const assertions: number = cards.length;
        t.plan(assertions);
        for (const card of cards) {
            const response = await t.notThrows(DataAPIClient.getCard(access_token, card.account_id));
        }
    });
github TrueLayer / truelayer-client-javascript / test / integration / integration.spec.ts View on Github external
const accounts: TrueLayer.IAccount[] = resp.results;
        const assertions: number = accounts.length;
        t.plan(assertions);
        for (const account of accounts) {
            const response = await t.notThrows(DataAPIClient.getBalance(access_token, account.account_id));
        }
    });

    test.serial("Get /accounts/{id}/balance returns error - invalid token", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getBalance("invalid_token", "invalid_account"));
        t.is(error.error, "invalid_access_token");
        t.is(error.message, "Invalid access token.");
    });

    test.serial("Get /accounts/{id}/balance returns error - invalid account", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getBalance(access_token, "invalid_account"));
        t.is(error.error, "account_not_found");
        t.is(error.message, "account not found");
    });

    /** cards **/
    test.serial("Get /cards returns success", async (t) => {
        t.plan(1);
        const response = await t.notThrows(DataAPIClient.getCards(access_token));
    });

    test.serial("Get /cards returns error - invalid token", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getCards("invalid_token"));
        t.is(error.error, "invalid_access_token");
github jasongin / nvs / test / modules / upgradeTests.js View on Github external
return nvsUpgrade.upgradeAsync().then(message => {
		t.regex(message[0], /^Mock used/);
		t.regex(message[1], /^Mock removed/);
		t.is(mockNvsUse.useCalls.length, 1);
		t.is(mockNvsUse.useCalls[0], v2);
		t.is(mockNvsLink.linkCalls.length, 0);
		t.is(mockNvsAddRemove.addCalls.length, 0);
		t.is(mockNvsAddRemove.removeCalls.length, 1);
		t.is(mockNvsAddRemove.removeCalls[0].semanticVersion, v1.semanticVersion);
		t.is(mockNvsMigrate.migrateCalls.length, 1);
		t.is(mockNvsMigrate.migrateCalls[0][0].semanticVersion, v1.semanticVersion);
		t.is(mockNvsMigrate.migrateCalls[0][1].semanticVersion, v2.semanticVersion);
	});
});

test.serial('Upgrade linked version', t => {
	const v1 = NodeVersion.parse('3.4.5');
	const v2 = NodeVersion.parse('3.5.0');
	mockNvsList.localVersions = [ v2, v1 ];
	mockNvsList.remoteVersions = mockNvsList.localVersions;
	v1.arch = NodeVersion.defaultArch;
	v1.os = NodeVersion.defaultOs;
	mockNvsLink.linkedVersion = v1;
	return nvsUpgrade.upgradeAsync(v1).then(message => {
		t.regex(message[0], /^Mock linked/);
		t.regex(message[1], /^Mock removed/);
		t.is(mockNvsUse.useCalls.length, 0);
		t.is(mockNvsLink.linkCalls.length, 1);
		t.is(mockNvsLink.linkCalls[0], v2);
		t.is(mockNvsAddRemove.addCalls.length, 0);
		t.is(mockNvsAddRemove.removeCalls.length, 1);
		t.is(mockNvsAddRemove.removeCalls[0].semanticVersion, v1.semanticVersion);
github TrueLayer / truelayer-client-javascript / test / integration / integration.spec.ts View on Github external
const error: ApiError = await t.throws(DataAPIClient.getCard(access_token, "invalid_account"));
        t.is(error.error, "account_not_found");
        t.is(error.message, "account not found");
    });

    test.serial("Get /cards/{id}/balance returns success for each card account", async (t) => {
        const resp = await DataAPIClient.getCards(access_token);
        const cards: TrueLayer.ICard[] = resp.results;
        const assertions: number = cards.length;
        t.plan(assertions);
        for (const card of cards) {
            const response = await t.notThrows(DataAPIClient.getCardBalance(access_token, card.account_id));
        }
    });

    test.serial("Get /cards/{id}/balance returns error - invalid token", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getCardBalance("invalid_token", "invalid_account"));
        t.is(error.error, "invalid_access_token");
        t.is(error.message, "Invalid access token.");
    });

    test.serial("Get /cards/{id}/balance returns error - invalid account", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getCardBalance(access_token, "invalid_account"));
        t.is(error.error, "account_not_found");
        t.is(error.message, "account not found");
    });

    test.serial("Get /cards/{id}/transactions returns success for each account", async (t) => {
        const resp = await DataAPIClient.getCards(access_token);
        const cards: TrueLayer.ICard[] = resp.results;
github TrueLayer / truelayer-client-javascript / test / integration / integration.spec.ts View on Github external
const error: ApiError = await t.throws(DataAPIClient.getCards("invalid_token"));
        t.is(error.error, "invalid_access_token");
        t.is(error.message, "Invalid access token.");
    });

    test.serial("Get /cards returns success for each result account", async (t) => {
        const resp = await DataAPIClient.getCards(access_token);
        const cards: TrueLayer.ICard[] = resp.results;
        const assertions: number = cards.length;
        t.plan(assertions);
        for (const card of cards) {
            const response = await t.notThrows(DataAPIClient.getCard(access_token, card.account_id));
        }
    });

    test.serial("Get /card returns error - invalid token", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getCard("invalid_token", "account"));
        t.is(error.error, "invalid_access_token");
        t.is(error.message, "Invalid access token.");
    });

    test.serial("Get /card returns error - invalid account", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getCard(access_token, "invalid_account"));
        t.is(error.error, "account_not_found");
        t.is(error.message, "account not found");
    });

    test.serial("Get /cards/{id}/balance returns success for each card account", async (t) => {
        const resp = await DataAPIClient.getCards(access_token);
        const cards: TrueLayer.ICard[] = resp.results;
github TrueLayer / truelayer-client-javascript / test / integration / integration.spec.ts View on Github external
test.serial("Get /account returns error - invalid token", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getAccount("invalid_token", "account"));
        t.is(error.error, "invalid_access_token");
        t.is(error.message, "Invalid access token.");
    });

    test.serial("Get /account returns error - invalid account", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getAccount(access_token, "invalid_account"));
        t.is(error.error, "account_not_found");
        t.is(error.message, "account not found");
    });

    test.serial("Get /accounts/{id}/transactions returns success for each account", async (t) => {
        const resp = await DataAPIClient.getAccounts(access_token);
        const accounts: TrueLayer.IAccount[] = resp.results;
        const assertions: number = accounts.length;
        t.plan(assertions);
        const from: string = moment().subtract(1, "month").format("YYYY-MM-DD");
        const to: string = moment().format("YYYY-MM-DD");
        for (const account of accounts) {
            const response = await t.notThrows(DataAPIClient.getTransactions(access_token, account.account_id, from, to));
        }
    });

    test.serial("Get /accounts/{id}/transactions returns error - invalid token", async (t) => {
        t.plan(3);
        const error: ApiError = await t.throws(DataAPIClient.getTransactions("invalid_token", "invalid_account", "2017-05-05", "2017-05-07"));
        t.is(error.error, "invalid_access_token");
        t.is(error.message, "Invalid access token.");
github TrueLayer / truelayer-client-javascript / test / unit / data.spec.ts View on Github external
const expected = fixtures.meResponse;
        mock.stub(request, "get").returns(JSON.stringify(expected));
        const actual = await DataAPIClient.getMe(access_token);
        t.plan(1);
        t.deepEqual(actual, expected);
    });

    test.serial("stubbed request body for /Info endpoint is correctly parsed", async (t) => {
        const expected = fixtures.infoResponse;
        mock.stub(request, "get").returns(JSON.stringify(expected));
        const actual = await DataAPIClient.getInfo(access_token);
        t.plan(1);
        t.deepEqual(actual, expected);
    });

    test.serial("stubbed request body for /Accounts endpoint is correctly parsed", async (t) => {
        const expected = fixtures.accountsResponse;
        mock.stub(request, "get").returns(JSON.stringify(expected));
        const actual = await DataAPIClient.getAccounts(access_token);
        t.plan(1);
        t.deepEqual(actual, expected);
    });

    test.serial("stubbed request body for /Accounts/{id} endpoint.deepEqual correctly parsed", async (t) => {
        const expected = fixtures.accountsResponse;
        mock.stub(request, "get").returns(JSON.stringify(expected));
        const actual = await DataAPIClient.getAccount(access_token, "test_account_id");
        t.plan(1);
        t.deepEqual(actual, expected);
    });

    test.serial("stubbed request body for /Accounts/{id}/Balance endpoint is correctly parsed", async (t) => {