Updating js plugins

This commit is contained in:
ahwelp
2023-01-24 20:31:23 +00:00
parent b1eb0a7a56
commit 2b6ddf9569
602 changed files with 109412 additions and 18 deletions
@@ -0,0 +1,6 @@
{
"extends": "../.eslintrc",
"parserOptions": {
"ecmaVersion": 2017
}
}
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<script src='https://unpkg.com/requirejs@2.3.6/require.js'></script>
<script>
require.config({
paths: {
mustache: '../../../mustache'
}
});
// Placed here rather in the -test.js file because it makes debugging in
// a local browser simpler because this .html file can be opened by double
// clicking the file and inspecting any errors/unexpected results
requirejs(['mustache'], Mustache => {
document.body.textContent = Mustache.render(
'{{title}} spends {{calc}}',
{
title: 'Joe',
calc: () => 2 + 4
});
});
</script>
</head>
<body>Text content to be overwritten<body>
</html>
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<script src='../../../mustache.js'></script>
</head>
<body>Text content to be overwritten<body>
<script>
document.body.textContent = Mustache.render(
'{{title}} spends {{calc}}',
{
title: 'Joe',
calc: () => 2 + 4
});
</script>
</html>
@@ -0,0 +1,49 @@
const fs = require('fs');
const path = require('path');
const puppeteer = require('puppeteer');
const chai = require('chai');
const mustache = fs.readFileSync(path.join(__dirname, '../../mustache.js'), 'utf8');
describe('Browser usage', () => {
let browser;
let page;
before(async function () {
this.timeout(10 * 1000);
// Awkward .launch() options below are needed to avoid hitting timeouts
// when tests are run in GitHub Actions for some weird reason
// https://github.com/GoogleChrome/puppeteer/issues/4617
browser = await puppeteer.launch({ignoreDefaultArgs: ['--disable-extensions']});
page = await browser.newPage();
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
page.on('pageerror', err => console.error('PAGE ERROR:', err));
});
after(() => browser.close());
it('is exposed on the global scope as window.Mustache', async () => {
await page.goto(`file://${path.join(__dirname, '_fixtures/global-scope.html')}`);
const bodyElement = await page.$('body');
const textContentProperty = await bodyElement.getProperty('textContent');
const value = await textContentProperty.jsonValue();
chai.assert.equal(value.trim(), 'Joe spends 6');
});
it('is exposed as AMD and consumable via RequireJS', async function () {
this.timeout(10 * 1000);
await page.goto(`file://${path.join(__dirname, '_fixtures/amd.html')}`, { waitUntil: 'networkidle0' });
const bodyElement = await page.$('body');
const textContentProperty = await bodyElement.getProperty('textContent');
const value = await textContentProperty.jsonValue();
chai.assert.equal(value, 'Joe spends 6');
});
});
@@ -0,0 +1,12 @@
const assert = require('assert');
const mustache = require('mustache');
const view = {
title: 'Joe',
calc: () => 2 + 4
};
assert.strictEqual(
mustache.render('{{title}} spends {{calc}}', view),
'Joe spends 6'
);
@@ -0,0 +1,16 @@
import { assertEquals } from "https://deno.land/std@0.51.0/testing/asserts.ts";
import mustache from "../../mustache.mjs";
const view = {
title: "Joe",
calc: function() {
return 2 + 4;
}
};
Deno.test("can use mustache", () => {
assertEquals(
mustache.render("{{title}} spends {{calc}}", view),
"Joe spends 6"
);
});
@@ -0,0 +1,12 @@
import assert from 'assert';
import mustache from 'mustache';
const view = {
title: 'Joe',
calc: () => 2 + 4
};
assert.strictEqual(
mustache.render('{{title}} spends {{calc}}', view),
'Joe spends 6'
);
@@ -0,0 +1,12 @@
import assert from 'assert';
import mustache from 'mustache/mustache.mjs';
const view = {
title: 'Joe',
calc: () => 2 + 4
};
assert.strictEqual(
mustache.render('{{title}} spends {{calc}}', view),
'Joe spends 6'
);