Skip to content
Permalink
Browse files

feat(testing): added jasmine for testing

  • Loading branch information
itmayziii committed Jun 26, 2019
1 parent 07f1b6b commit 907403f0f8680b73c25dfcf080a0629edd57f303
Showing with 391 additions and 1,800 deletions.
  1. +32 −0 gatsby-ssr.spec.js
  2. +31 −0 head-components-data.js
  3. +9 −0 jasmine.json
  4. +230 −1,794 package-lock.json
  5. +8 −1 package.json
  6. +38 −0 src/gatsby-ssr.spec.ts
  7. +2 −2 src/gatsby-ssr.ts
  8. +31 −0 src/head-components-data.ts
  9. +1 −3 tsconfig.json
  10. +9 −0 tslint.json
@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var gatsby_ssr_1 = require("./gatsby-ssr");
describe('gatsby-ssr.js', function () {
describe('onRenderBody', function () {
it('throws an error when no scripts are passed in', function () {
// @ts-ignore
expect(function () { gatsby_ssr_1.onRenderBody({}); }).toThrow(new Error('gatsby-plugin-no-javascript: Gatsby removed an internal detail that this plugin relied upon, please submit this issue to https://www.github.com/itmayziii/gatsby-plugin-no-javascript.'));
});
});
describe('onPreRenderHTML', function () {
it('does not remove non react components', function () {
var fakeHeadComponents = [
{
type: 'link',
key: 'styles-module1.css'
},
{
type: 'link',
key: 'styles-module2.css'
}
];
function getHeadComponents() {
return fakeHeadComponents;
}
var replaceHeadComponents = jasmine.createSpy('replaceHeadComponents');
// @ts-ignore
gatsby_ssr_1.onPreRenderHTML({ getHeadComponents: getHeadComponents, replaceHeadComponents: replaceHeadComponents });
expect(replaceHeadComponents).toHaveBeenCalledWith([fakeHeadComponents[0], fakeHeadComponents[1]]);
});
});
});
@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.headComponentsData = [{
type: 'link',
key: 'component---src-pages-schedule-a-pickup-php-js-a6d963769d2dc276611e.js',
ref: null,
props: {
as: 'script',
rel: 'preload',
href: '/component---src-pages-schedule-a-pickup-php-js-a6d963769d2dc276611e.js'
},
_owner: null
},
{
type: 'link',
key: 'styles-module1.css',
ref: null,
props: {
as: 'stylesheet',
rel: 'preload',
href: '/styles-module1.css'
},
_owner: null
},
{
type: 'link',
key: 'styles-module2.css',
ref: null,
_owner: null
}
];
@@ -0,0 +1,9 @@
{
"spec_dir": "./",
"spec_files": [
"**/*[sS]pec.js",
"!node_modules/**/*.js"
],
"stopSpecOnExpectationFailure": false,
"random": true
}

0 comments on commit 907403f

Please sign in to comment.
You can’t perform that action at this time.