-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use shared global type definitions * Fix non-relative pathing for imports * Integrate test double library sinon as a global * Rework expect to make it a global * Integrate mocha-gherkin across all packages * Rewrite loopback black-box test using mocha-gherkin syntax * Remove unused .eslintignore in package loopback * Simply bootstrapping tests * Fix Application constructor and start methods
- Loading branch information
1 parent
2a4d263
commit 1808d9f
Showing
35 changed files
with
224 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
// Use IntelliSense to learn about possible Node.js debug attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch Program", | ||
"program": "${workspaceRoot}/app.js", | ||
"cwd": "${workspaceRoot}" | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "attach", | ||
"name": "Attach to Process", | ||
"port": 5858 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "./node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "0.1.0", | ||
"command": "lerna", | ||
"isShellCommand": true, | ||
"echo command": true, | ||
"showOutput": "always", | ||
"suppressTaskName": true, | ||
"tasks": [ | ||
// Installing dependencies | ||
{ | ||
"taskName": "Install dependencies", | ||
"args": ["exec", "npm", "install"] | ||
}, | ||
{ | ||
"taskName": "Install loopback dependencies", | ||
"args": ["exec", "npm", "install", "--scope", "loopback"] | ||
}, | ||
{ | ||
"taskName": "Install juggler dependencies", | ||
"args": ["exec", "npm", "install", "--scope", "@loopback/juggler"] | ||
}, | ||
{ | ||
"taskName": "Install remoting dependencies", | ||
"args": ["exec", "npm", "install", "--scope", "@loopback/remoting"] | ||
}, | ||
// Running tests | ||
{ | ||
// run all tests for every package | ||
"taskName": "test", // DO NOT CHANGE (used for vscode ctrl+shift+t keybinding) | ||
"args": ["run", "test"], | ||
"isTestCommand": true | ||
}, | ||
{ | ||
"taskName": "Run loopback tests", | ||
"args": ["run", "test", "--scope", "loopback"] | ||
}, | ||
{ | ||
"taskName": "Run juggler tests", | ||
"args": ["run", "test", "--scope", "@loopback/juggler"] | ||
}, | ||
{ | ||
"taskName": "Run remoting tests", | ||
"args": ["run", "test", "--scope", "@loopback/remoting"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import {expect} from '../../../../test/expect'; | ||
|
||
suite('black-box smoke test', () => { | ||
test('passes', () => { | ||
describe('white-box smoke test', () => { | ||
it('passes', () => { | ||
expect(true).to.be.true(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import {expect} from '../../../../test/expect'; | ||
|
||
describe('white-box smoke test', () => { | ||
it('passes', () => { | ||
suite('white-box smoke test', () => { | ||
test('passes', () => { | ||
expect(true).to.be.true(); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,4 @@ language: node_js | |
node_js: | ||
- "4" | ||
- "6" | ||
- "7" | ||
|
||
- "7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { | ||
Application, | ||
AppConfig, | ||
AppState | ||
} from './lib/application'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
import http = require('http'); | ||
|
||
import bluebird = require('bluebird'); | ||
|
||
export interface AppConfig { | ||
port : number; | ||
} | ||
|
||
export enum AppState { | ||
cold, | ||
starting, | ||
listening, | ||
crashed, | ||
stopped | ||
} | ||
|
||
export class Application { | ||
constructor(public config : AppConfig) { | ||
// get runtime to enforce AppConfig as AppConfig | ||
constructor(public config?: AppConfig) { | ||
if (config === undefined) { | ||
this.config = {port: 3000}; | ||
} | ||
} | ||
public start() : Promise<void> { | ||
let server = http.createServer((req, res) => { | ||
|
||
public state: AppState = AppState.cold; | ||
|
||
async start() { | ||
this.state = AppState.starting; | ||
const server = http.createServer((req, res) => { | ||
res.end(); | ||
}); | ||
let listen = bluebird.promisify(server.listen, {context: server}); | ||
|
||
return listen(this.config.port); | ||
const listen = bluebird.promisify(server.listen, {context: server}); | ||
await listen(this.config.port); | ||
this.state = AppState.listening; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as util from 'loopback/test/support/util'; | ||
|
||
Feature('Bootstrapping', | ||
'In order to serve up my API', | ||
'As a user', | ||
'I want to start the app', () => { | ||
Scenario('with default configs', () => { | ||
let app; | ||
let client; | ||
|
||
Given('an app', () => { | ||
app = util.createApp(); | ||
}); | ||
And('a client', () => { | ||
client = util.createClient(app); | ||
}); | ||
When('the app is started (on port 3000 by default)', async () => { | ||
await app.start(); | ||
}); | ||
Then('the app responds with HTTP 200 when a request is sent to GET /', async () => { | ||
const result = await client.get('/') | ||
expect(result.statusCode).to.equal(200); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
import { Application, AppConfig } from '../../loopback'; | ||
import { Application, AppConfig } from 'loopback'; | ||
import { Client } from './client'; | ||
|
||
|
||
class Util { | ||
public createApp(config: AppConfig) : Application { | ||
return new Application(config); | ||
} | ||
public createClient(app : Application) { | ||
return new Client(app); | ||
} | ||
export function createApp(config?: AppConfig) : Application { | ||
return new Application(config); | ||
} | ||
|
||
|
||
|
||
export default new Util; | ||
export function createClient(app : Application) { | ||
return new Client(app); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {Application, AppState} from 'loopback'; | ||
|
||
suite('Application', () => { | ||
suite('constructor(config?: AppConfig)', () => { | ||
test('without config arg', () => { | ||
const app = new Application(); | ||
expect(app.config).to.be.an('object'); | ||
expect(app.config.port).to.eql(3000); | ||
}); | ||
}) | ||
|
||
suite('start()', () => { | ||
test('when state is cold', async () => { | ||
const app = new Application(); | ||
expect(app.state).to.equal(AppState.cold); | ||
await app.start(); | ||
expect(app.state).to.equal(AppState.listening); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import {expect} from '../../../../test/expect'; | ||
|
||
suite('black-box smoke test', () => { | ||
test('passes', () => { | ||
describe('black-box smoke test', () => { | ||
it('passes', () => { | ||
expect(true).to.be.true(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.