Skip to content

Commit

Permalink
docs: clean tests a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianCataldo committed Feb 9, 2024
1 parent 4ed8d04 commit 87f227c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,30 @@ _The gist is_:

import { html, styled, OG_SIZE, FONTS } from 'og-images-generator';

const style1 = styled.div`
display: flex;
`;

/** @type {import('og-images-generator').PathsOptions} */
/** @type {import('og-images-generator').PathsOptions} (Optional) */
export const paths = {
// DEFAULTS:
base: './dist',
out: './dist/og',
json: './dist/og/index.json',
};

const myInlineStyle1 = styled.div`
display: flex;
`;

const nestedTemplate1 = html`<span>My Website</span>`;

/** @type {import('og-images-generator').Template} */
export const template = ({ page }) =>
html` <!-- Contrived example -->
<div style=${style1}>
${page.meta?.tags['og:title']} - ${page.meta?.tags['og:description']}
<div style=${myInlineStyle1}>
${page.meta?.tags?.['og:title'] ?? 'Untitled'} <br />
${page.meta?.tags?.['og:description'] ?? 'No description'}
<!-- -->
${nestedTemplate1}
<em>Nice</em>
<strong>Weather</strong>
</div>`;
/** @type {import('og-images-generator').RenderOptions} */
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "og-images-generator",
"version": "0.0.7",
"version": "0.0.8",
"description": "Generate OG images from a static folder and / or a middleware.\nExtract metadata from HTML pages. No headless browser involved.\nComes as a CLI, API or plugins.",
"keywords": [
"og-images",
"social-networks",
"open-graph",
"svg-png",
"static",
"seo",
Expand Down Expand Up @@ -62,9 +63,9 @@
"dev:test": "npm run test -- --watch",
"types": "npm run clean && npx tsc --project tsconfig.build.json",
"clean": "rm -rf ./types",
"test": "node --test",
"test": "node --test ./test/*.test.js",
"build:docs": "typedoc --tsconfig tsconfig.build.json --entryPoints src/index.js src/api.js",
"release": "npm run types && npm publish"
"release": "npm run test && npm run types && npm publish"
},
"devDependencies": {
"@types/node": "^20.11.16",
Expand Down
20 changes: 11 additions & 9 deletions test/__fixtures__/og-images.config.fixture.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import { html, styled, OG_SIZE, FONTS } from 'og-images-generator';

const style1 = styled.div`
display: flex;
`;

/** @type {import('og-images-generator').PathsOptions} */
/** @type {import('og-images-generator').PathsOptions} (Optional) */
export const paths = {
// DEFAULTS:
base: './dist',
out: './dist/og',
json: './dist/og/index.json',
};

const nestedTemplate = html`<span>My Website</span>`;
const myInlineStyle1 = styled.div`
display: flex;
`;

const nestedTemplate1 = html`<span>My Website</span>`;

/** @type {import('og-images-generator').Template} */
export const template = ({ page }) =>
html` <!-- Contrived example -->
<div style=${style1}>
${page.meta?.tags['og:title']} - ${page.meta?.tags['og:description']}
${nestedTemplate}
<div style=${myInlineStyle1}>
${page.meta?.tags?.['og:title'] ?? 'Untitled'} <br />
${page.meta?.tags?.['og:description'] ?? 'No description'}
<!-- -->
${nestedTemplate1}
<em>Nice</em>
<strong>Weather</strong>
</div>`;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions test/index.js → test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'node:test';
import assert from 'node:assert';

import * as api from '../src/api.js';
import { hash } from './utils.js';
import { hash } from './_utils.js';

const options = {
base: process.cwd() + '/test/__fixtures__/pages',
Expand Down Expand Up @@ -45,5 +45,5 @@ test('Generate single image', async (t) => {
},
});

assert.equal(hash(image), 'eb03b3d1afe7c4b5a8d55c5f255e0c8a');
assert.equal(hash(image), 'ad6a8e499e03a59a1c29e490e7d3f424');
});

0 comments on commit 87f227c

Please sign in to comment.