Skip to content

Commit

Permalink
Issue-1016: Additional removal of request
Browse files Browse the repository at this point in the history
  • Loading branch information
DevLab2425 committed Oct 19, 2023
1 parent 741a667 commit 6625ee9
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 77 deletions.
4 changes: 3 additions & 1 deletion .mocharc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module.exports = {
timeout: 90000
timeout: 90000,
bail: true,
exit: true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Develop Greenwood With: ', function() {
let runner;

before(function() {
runner = new Runner(true);
runner = new Runner();
});

describe(LABEL, function() {
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('Develop Greenwood With: ', function() {
'content-type': 'application/json'
}
});
data = await response.text();
data = await response.json();
});

it('should return a 200 status', function() {
Expand All @@ -105,7 +105,7 @@ describe('Develop Greenwood With: ', function() {
});

it('should return the expected query response', function() {
expect(data.config.workspace).to.equal(new URL('./src/', import.meta.url).href);
expect(data.data.config.workspace).to.equal(new URL('./src/', import.meta.url).href);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Serve Greenwood With: ', function() {
const LABEL = 'A Server Rendered Application (SSR) with API Routes importing CSS';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = fileURLToPath(new URL('.', import.meta.url));
const hostname = 'http://127.0.0.1:8080';
const hostname = 'http://localhost:8080';
let runner;

before(async function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Develop Greenwood With: ', function() {
let data;

before(async function() {
response = await fetch(`http://localhost:${port}/main.json?type=json`);
response = await fetch(`${hostname}:${port}/main.json?type=json`);
data = await response.text();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import chai from 'chai';
import { JSDOM } from 'jsdom';
import path from 'path';
import { getSetupFiles, getOutputTeardownFiles } from '../../../../../test/utils.js';
import request from 'request';
import { Runner } from 'gallinago';
import { fileURLToPath } from 'url';

Expand All @@ -40,7 +39,7 @@ describe('Serve Greenwood With: ', function() {
const LABEL = 'A Server Rendered Application (SSR) with API Routes importing JSON';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = fileURLToPath(new URL('.', import.meta.url));
const hostname = 'http://127.0.0.1:8080';
const hostname = 'http://localhost:8080';
let runner;

before(async function() {
Expand Down Expand Up @@ -68,37 +67,25 @@ describe('Serve Greenwood With: ', function() {

describe('Serve command with HTML route response for products page', function() {
let response = {};
let data;
let productsPageDom;

before(async function() {
return new Promise((resolve, reject) => {
request.get(`${hostname}/products/`, (err, res, body) => {
if (err) {
reject();
}

response = res;
response.body = body;
productsPageDom = new JSDOM(body);

resolve();
});
});
response = await fetch(`${hostname}/products/`);
data = response.json();
productsPageDom = new JSDOM(data);
});

it('should return a 200 status', function(done) {
expect(response.statusCode).to.equal(200);
done();
it('should return a 200 status', function() {
expect(response.status).to.equal(200);
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.equal('text/html');
done();
it('should return the correct content type', function() {
expect(response.headers.get('content-type')).to.equal('text/html');
});

it('should return a response body', function(done) {
expect(response.body).to.not.be.undefined;
done();
it('should return a response body', function() {
expect(data).to.not.be.undefined;
});

it('should make sure to have the expected number of <app-card> components on the page', function(done) {
Expand All @@ -114,34 +101,19 @@ describe('Serve Greenwood With: ', function() {
let fragmentsApiDom;

before(async function() {
return new Promise((resolve, reject) => {
request.get(`${hostname}/api/fragment`, (err, res, body) => {
if (err) {
reject();
}

response = res;
response.body = body;
fragmentsApiDom = new JSDOM(body);

resolve();
});
});
response = await fetch(`${hostname}/api/fragment`);
});

it('should return a 200 status', function(done) {
expect(response.statusCode).to.equal(200);
done();
it('should return a 200 status', function() {
expect(response.status).to.equal(200);
});

it('should return a custom status message', function(done) {
it('should return a custom status message', function() {
expect(response.statusMessage).to.equal('OK');
done();
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.equal('text/html');
done();
it('should return the correct content type', function() {
expect(response.headers.get('content-type')).to.equal('text/html');
});

it('should make sure to have the expected number of <app-card> components in the fragment', function(done) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Develop Greenwood With: ', function() {
let data;

before(async function() {
response = await fetch(`http://127.0.0.1:${port}/main.ts`);
response = await fetch(`${hostname}:${port}/main.ts`);
data = await response.text();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import chai from 'chai';
import { JSDOM } from 'jsdom';
import path from 'path';
import { getSetupFiles, getOutputTeardownFiles } from '../../../../../test/utils.js';
import request from 'request';
import { Runner } from 'gallinago';
import { fileURLToPath } from 'url';

Expand All @@ -36,7 +35,7 @@ describe('Serve Greenwood With: ', function() {
const LABEL = 'A Server Rendered Application (SSR) with API Routes importing TypeScript';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = fileURLToPath(new URL('.', import.meta.url));
const hostname = 'http://127.0.0.1:8080';
const hostname = 'http://localhost:8080';
let runner;

before(async function() {
Expand All @@ -62,40 +61,27 @@ describe('Serve Greenwood With: ', function() {
});
});

describe('Serve command with API specific behaviors for an HTML ("fragment") API', function() {
describe.only('Serve command with API specific behaviors for an HTML ("fragment") API', function() {

Check failure on line 64 in packages/plugin-typescript/test/cases/exp-serve.ssr/exp-serve.ssr.spec.js

View workflow job for this annotation

GitHub Actions / build (18)

describe.only not permitted

Check failure on line 64 in packages/plugin-typescript/test/cases/exp-serve.ssr/exp-serve.ssr.spec.js

View workflow job for this annotation

GitHub Actions / build (18)

describe.only not permitted
let response = {};
let data;
let fragmentsApiDom;

before(async function() {
return new Promise((resolve, reject) => {
request.get(`${hostname}/api/fragment`, (err, res, body) => {
if (err) {
reject();
}

console.log({ body });
response = res;
response.body = body;
fragmentsApiDom = new JSDOM(body);

resolve();
});
});
response = await fetch(`${hostname}/api/fragment`);
data = await response.json();
fragmentsApiDom = new JSDOM(data);
});

it('should return a 200 status', function(done) {
expect(response.statusCode).to.equal(200);
done();
it('should return a 200 status', function() {
expect(response.status).to.equal(200);
});

it('should return a custom status message', function(done) {
it('should return a custom status message', function() {
expect(response.statusMessage).to.equal('OK');
done();
});

it('should return the correct content type', function(done) {
expect(response.headers['content-type']).to.equal('text/html');
done();
it('should return the correct content type', function() {
expect(response.headers.get('content-type')).to.equal('text/html');
});

it('should make sure to have the expected CSS inlined into the page for each <app-card>', function(done) {
Expand Down

0 comments on commit 6625ee9

Please sign in to comment.