From 53346690a4d831c0594956b4f4823d752bb7514b Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Tue, 25 Sep 2018 11:01:36 -0700 Subject: [PATCH] chore: simplify test cases Signed-off-by: Raymond Feng --- test/acceptance/home-page.controller.acceptance.ts | 8 ++++++++ test/acceptance/ping.controller.acceptance.ts | 4 ++-- test/acceptance/shopping-cart.controller.acceptance.ts | 4 ++-- test/acceptance/user.controller.acceptance.ts | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/test/acceptance/home-page.controller.acceptance.ts b/test/acceptance/home-page.controller.acceptance.ts index 2c5d3f6cc..9529deacc 100644 --- a/test/acceptance/home-page.controller.acceptance.ts +++ b/test/acceptance/home-page.controller.acceptance.ts @@ -5,13 +5,17 @@ import {createRestAppClient, Client, expect} from '@loopback/testlab'; import {ShoppingApplication} from '../..'; +import {RestServer} from '@loopback/rest'; describe('HomePageController', () => { let app: ShoppingApplication; + let server: RestServer; let client: Client; before(givenAnApplication); + before(givenARestServer); + before(async () => { await app.boot(); await app.start(); @@ -40,4 +44,8 @@ describe('HomePageController', () => { }, }); } + + async function givenARestServer() { + server = await app.getServer(RestServer); + } }); diff --git a/test/acceptance/ping.controller.acceptance.ts b/test/acceptance/ping.controller.acceptance.ts index 058bccdbb..f8365a409 100644 --- a/test/acceptance/ping.controller.acceptance.ts +++ b/test/acceptance/ping.controller.acceptance.ts @@ -3,14 +3,14 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {createClientForHandler, supertest, expect} from '@loopback/testlab'; +import {createClientForHandler, Client, expect} from '@loopback/testlab'; import {RestServer} from '@loopback/rest'; import {ShoppingApplication} from '../..'; describe('PingController', () => { let app: ShoppingApplication; let server: RestServer; - let client: supertest.SuperTest; + let client: Client; before(givenAnApplication); diff --git a/test/acceptance/shopping-cart.controller.acceptance.ts b/test/acceptance/shopping-cart.controller.acceptance.ts index 7dcfcd374..1390d1674 100644 --- a/test/acceptance/shopping-cart.controller.acceptance.ts +++ b/test/acceptance/shopping-cart.controller.acceptance.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {createClientForHandler, supertest, expect} from '@loopback/testlab'; +import {createClientForHandler, Client, expect} from '@loopback/testlab'; import {RestServer} from '@loopback/rest'; import {ShoppingApplication} from '../..'; import {ShoppingCartRepository} from '../../src/repositories'; @@ -13,7 +13,7 @@ import {ShoppingCart, ShoppingCartItem} from '../../src/models'; describe('ShoppingCartController', () => { let app: ShoppingApplication; let server: RestServer; - let client: supertest.SuperTest; + let client: Client; const cartRepo = new ShoppingCartRepository(new RedisDataSource()); before(givenAnApplication); diff --git a/test/acceptance/user.controller.acceptance.ts b/test/acceptance/user.controller.acceptance.ts index 7a5025f1a..7fe7b810f 100644 --- a/test/acceptance/user.controller.acceptance.ts +++ b/test/acceptance/user.controller.acceptance.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {createClientForHandler, supertest, expect} from '@loopback/testlab'; +import {createClientForHandler, Client, expect} from '@loopback/testlab'; import {RestServer} from '@loopback/rest'; import {ShoppingApplication} from '../..'; import {UserRepository} from '../../src/repositories'; @@ -12,7 +12,7 @@ import {UserDataSource} from '../../src/datasources'; describe('UserController', () => { let app: ShoppingApplication; let server: RestServer; - let client: supertest.SuperTest; + let client: Client; const userRepo = new UserRepository(new UserDataSource()); const user = {