Skip to content

Commit

Permalink
chore: simplify test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Raymond Feng <[email protected]>
  • Loading branch information
raymondfeng committed Sep 25, 2018
1 parent f0c76eb commit 5334669
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions test/acceptance/home-page.controller.acceptance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -40,4 +44,8 @@ describe('HomePageController', () => {
},
});
}

async function givenARestServer() {
server = await app.getServer(RestServer);
}
});
4 changes: 2 additions & 2 deletions test/acceptance/ping.controller.acceptance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<supertest.Test>;
let client: Client;

before(givenAnApplication);

Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/shopping-cart.controller.acceptance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -13,7 +13,7 @@ import {ShoppingCart, ShoppingCartItem} from '../../src/models';
describe('ShoppingCartController', () => {
let app: ShoppingApplication;
let server: RestServer;
let client: supertest.SuperTest<supertest.Test>;
let client: Client;
const cartRepo = new ShoppingCartRepository(new RedisDataSource());

before(givenAnApplication);
Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/user.controller.acceptance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -12,7 +12,7 @@ import {UserDataSource} from '../../src/datasources';
describe('UserController', () => {
let app: ShoppingApplication;
let server: RestServer;
let client: supertest.SuperTest<supertest.Test>;
let client: Client;
const userRepo = new UserRepository(new UserDataSource());

const user = {
Expand Down

0 comments on commit 5334669

Please sign in to comment.