Skip to content

Commit

Permalink
divide tests into categories
Browse files Browse the repository at this point in the history
  • Loading branch information
Asad Memon committed Jan 28, 2019
1 parent 49fd96b commit fe59e08
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 41 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module.exports = {
rootDir: 'test',
testEnvironment: "node",
testMatch: [ "**/test/integration/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ],
globalSetup: '<rootDir>/jest-global-setup.js',
globalTeardown: '<rootDir>/jest-global-teardown.js',
setupTestFrameworkScriptFile: '<rootDir>/jest.setup.js'
Expand Down
17 changes: 17 additions & 0 deletions test/integration/lambda.js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const {get} = require("../request")
const cheerio = require('cheerio')

// JS Lambda
test('JS Lambda in root folder', () => {
// expect.assertions(1);
return get("/").then(data => {
expect(data).toBe('Hello');
});
});

test('Login and redirect', () => {
// expect.assertions(1);
return get("/api/login", {jar: true, json: true}).then(data => {
expect(data.id).toBe('asad');
});
});
20 changes: 20 additions & 0 deletions test/integration/lambda.react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const {get} = require("../request")
const cheerio = require('cheerio')

// React Lambda
test('React Stateless', () => {
//expect.assertions(1);
return get("/react/stateless").then(data => {
const $ = cheerio.load(data)
expect($('body').text().trim()).toBe("react-stateless");
});
});


test('React With Imports', () => {
//expect.assertions(1);
return get("/react/withimports").then(data => {
const $ = cheerio.load(data)
expect($('body').text().trim()).toBe("246");
});
});
18 changes: 18 additions & 0 deletions test/integration/matchPaths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const {get} = require("../request")
const cheerio = require('cheerio')

// Path matching
test('Html file in root folder', () => {
// expect.assertions(1);
return get("/heading").then(data => {
const $ = cheerio.load(data)
expect($('h1').text().trim()).toBe("title");
});
});

test('Txt file in root folder', () => {
// expect.assertions(1);
return get("/text.txt").then(data => {
expect(data).toBe("text content");
});
});
2 changes: 1 addition & 1 deletion test/jest-global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require("path")
const startServer = require("../packages/core/lib")

module.exports = async function globalSetup () {
await startServer(path.join(__dirname, "./files"))
await startServer(path.join(__dirname, "./www"))

await waitPort({
//host: "http://localhost",
Expand Down
2 changes: 1 addition & 1 deletion test/startServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require("path")
const startServer = require("../packages/core/lib")

async function globalSetup () {
await startServer(path.join(__dirname, "./files"))
await startServer(path.join(__dirname, "./www"))

await waitPort({
//host: "http://localhost",
Expand Down
39 changes: 0 additions & 39 deletions test/test.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions test/www/react/withimports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const React = require('react')

var _ = require('underscore');


const HelloWorld = props => {
return (
<React.Fragment>
{_.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 != 0)}
</React.Fragment>
)
}

module.exports =HelloWorld
File renamed without changes.

0 comments on commit fe59e08

Please sign in to comment.