[EDIT] FILE: index.test.js.tar
home/koolde6/public_html/lovestrong/server/node_modules/pstree.remy/tests/index.test.js 0000755 00000002553 15073757732 0025620 0 ustar 00 const tap = require('tap'); const test = tap.test; const readFile = require('fs').readFileSync; const spawn = require('child_process').spawn; const pstree = require('../'); const { tree, pidsForTree, getStat } = require('../lib/utils'); if (process.platform !== 'darwin') { test('reads from /proc', async (t) => { const ps = await getStat(); t.ok(ps.split('\n').length > 1); }); } test('tree for live env', async (t) => { const pid = 4079; const fixture = readFile(__dirname + '/fixtures/out2', 'utf8'); const ps = await tree(fixture); t.deepEqual( pidsForTree(ps, pid).map((_) => _.PID), ['4080'] ); }); function testTree(t, runCallCount) { const sub = spawn('node', [`${__dirname}/fixtures/index.js`, runCallCount], { stdio: 'pipe', }); setTimeout(() => { const pid = sub.pid; pstree(pid, (error, pids) => { pids.concat([pid]).forEach((p) => { spawn('kill', ['-s', 'SIGTERM', p]); }); // the fixture launches `sh` which launches node which is why we // are looking for two processes. // Important: IDKW but MacOS seems to skip the `sh` process. no idea. t.equal(pids.length, runCallCount * 2); t.end(); }); }, 1000); } test('can read full process tree', (t) => { testTree(t, 1); }); test('can read full process tree with multiple processes', (t) => { testTree(t, 2); }); home/koolde6/public_html/lovestrong/frontend/node_modules/postcss-clamp/index.test.js 0000755 00000014533 15076653337 0025302 0 ustar 00 let postcss = require('postcss') let clamp = require('./') async function run (input, output, opts) { let result = await postcss([clamp(opts)]).process(input, { from: '/test.css' }) expect(result.css).toEqual(output) expect(result.warnings()).toHaveLength(0) return result } it('handle simple transformation (only values)', async () => { await run( 'a{ width: clamp(10px, 64px, 80px); }', 'a{ width: max(10px, min(64px, 80px)); }' ) }) it('handle simple transformation (only values) with preserve', async () => { await run( 'a{ width: clamp(10px, 64px, 80px); }', 'a{ width: max(10px, min(64px, 80px)); width: clamp(10px, 64px, 80px); }', { preserve: true } ) }) it('handle transformation with functions', async () => { await run( 'a{ width: clamp(calc(100% - 10px), min(10px, 100%), max(40px, 4em)); }', 'a{ width: max(calc(100% - 10px), min(min(10px, 100%), max(40px, 4em))); }' ) }) it('handle transformation with functions with preserve', async () => { await run( 'a{ width: clamp(calc(100% - 10px), min(10px, 100%), max(40px, 4em)); }', 'a{ width: max(calc(100% - 10px), min(min(10px, 100%), max(40px, 4em))); ' + 'width: clamp(calc(100% - 10px), min(10px, 100%), max(40px, 4em)); }', { preserve: true } ) }) it('handle transformation with different units', async () => { await run( 'a{ width: clamp(10%, 2px, 4rem); }', 'a{ width: max(10%, min(2px, 4rem)); }' ) }) it('handle transformation with different units and preserve', async () => { await run( 'a{ width: clamp(10%, 2px, 4rem); }', 'a{ width: max(10%, min(2px, 4rem)); width: clamp(10%, 2px, 4rem); }', { preserve: true } ) }) it('transform only function with 3 parameters', async () => { await run( 'a{ width: clamp(10%, 2px, 4rem);' + '\nheight: clamp(10px, 20px, 30px, 40px); }', 'a{ width: max(10%, min(2px, 4rem));' + '\nheight: clamp(10px, 20px, 30px, 40px); }' ) }) it('transform only clamp function', async () => { await run( 'a{ width: clamp(10%, 2px, 4rem);\nheight: calc(10px + 100%); }', 'a{ width: max(10%, min(2px, 4rem));\nheight: calc(10px + 100%); }' ) }) it('precalculate second and third with the same unit (int values)', async () => { await run('a{ width: clamp(10%, 2px, 5px); }', 'a{ width: max(10%, 7px); }', { precalculate: true }) }) it('precalculate second and third with the same unit (float values)', async () => { await run( 'a{ width: clamp(10%, 2.5px, 5.1px); }', 'a{ width: max(10%, 7.6px); }', { precalculate: true } ) }) it('precalculate second and third with the same unit (float and int values)', async () => { await run( 'a{ width: clamp(10%, 2.5px, 5px); }', 'a{ width: max(10%, 7.5px); }', { precalculate: true } ) }) it('precalculate 2nd & 3rd with the same unit (float and int vals) & preserve', async () => { await run( 'a{ width: clamp(10%, 2.5px, 5px); }', 'a{ width: max(10%, 7.5px); width: clamp(10%, 2.5px, 5px); }', { precalculate: true, preserve: true } ) }) it('precalculate all values with the same unit (int values)', async () => { await run('a{ width: clamp(10px, 2px, 5px); }', 'a{ width: 17px; }', { precalculate: true }) }) it('precalculate all values with the same unit (float values)', async () => { await run( 'a{ width: clamp(10.4px, 2.11px, 5.9px); }', 'a{ width: 18.41px; }', { precalculate: true } ) }) it('precalculate all values with the same unit (int and float values)', async () => { await run('a{ width: clamp(10.4px, 2px, 5.9px); }', 'a{ width: 18.3px; }', { precalculate: true }) }) it('handle function with enable precalculation as third', async () => { await run( 'a{ width: clamp(10px, 2px, calc(10px + 100%)); }', 'a{ width: max(10px, min(2px, calc(10px + 100%))); }', { precalculate: true } ) }) it('handle function with enable precalculation as second', async () => { await run( 'a{ width: clamp(10px, calc(10px + 100%), 2px); }', 'a{ width: max(10px, min(calc(10px + 100%), 2px)); }', { precalculate: true } ) }) it('handle function with enable precalculation as first', async () => { await run( 'a{ width: clamp(calc(10px + 100%), 10px, 2px); }', 'a{ width: max(calc(10px + 100%), 12px); }', { precalculate: true } ) }) it('handle function with enable precalculation as all', async () => { await run( 'a{ width: clamp(calc(10px + 100%), calc(10rem + 200%), 10px); }', 'a{ width: max(calc(10px + 100%), min(calc(10rem + 200%), 10px)); }', { precalculate: true } ) }) it('handle not valid values', async () => { await run('a{ width: clamp(a, b, c); }', 'a{ width: max(a, min(b, c)); }', { precalculate: true }) }) it('handle not valid values with preserve', async () => { await run( 'a{ width: clamp(a, b, c); }', 'a{ width: max(a, min(b, c)); width: clamp(a, b, c); }', { precalculate: true, preserve: true } ) }) it('handle not valid values mixed with valid', async () => { await run( 'a{ width: clamp(a, 1px, 2em); }', 'a{ width: max(a, min(1px, 2em)); }', { precalculate: true } ) }) it('handle not valid values mixed with valid and preserve', async () => { await run( 'a{ width: clamp(a, 1px, 2em); }', 'a{ width: max(a, min(1px, 2em)); width: clamp(a, 1px, 2em); }', { precalculate: true, preserve: true } ) }) it('handle complex values', async () => { await run( 'a{ grid-template-columns: clamp(22rem, 40%, 32rem) minmax(0, 1fr); }', 'a{ grid-template-columns: max(22rem, min(40%, 32rem)) minmax(0, 1fr); }' ) }) it('handle multiple complex values', async () => { await run( 'a{ margin: clamp(1rem, 2%, 3rem) 4px clamp(5rem, 6%, 7rem) 8rem; }', 'a{ margin: max(1rem, min(2%, 3rem)) 4px max(5rem, min(6%, 7rem)) 8rem; }' ) }) it('handle calc', async () => { await run( 'a{ margin: 0 40px 0 calc(-1 * clamp(32px, 16vw, 64px)); }', 'a{ margin: 0 40px 0 calc(-1 * max(32px, min(16vw, 64px))); }' ) }) it('handle multiple calc', async () => { await run( 'a{ margin: calc(-1 * clamp(1px, 2vw, 3px)) calc(-1 * clamp(4px, 5vw, 6px)); }', 'a{ margin: calc(-1 * max(1px, min(2vw, 3px))) calc(-1 * max(4px, min(5vw, 6px))); }' ) }) it('handle nested clamp', async () => { await run( 'a{ font-size: clamp(clamp(1rem, 2vw, 3rem), 4vw, 5rem); }', 'a{ font-size: max(max(1rem, min(2vw, 3rem)), min(4vw, 5rem)); }' ) }) home/koolde6/public_html/lovestrong/frontend/node_modules/gensync/test/index.test.js 0000755 00000025413 15076703421 0025124 0 ustar 00 "use strict"; const promisify = require("util.promisify"); const gensync = require("../"); const TEST_ERROR = new Error("TEST_ERROR"); const DID_ERROR = new Error("DID_ERROR"); const doSuccess = gensync({ sync: () => 42, async: () => Promise.resolve(42), }); const doError = gensync({ sync: () => { throw DID_ERROR; }, async: () => Promise.reject(DID_ERROR), }); function throwTestError() { throw TEST_ERROR; } async function expectResult( fn, arg, { error, value, expectSync = false, syncErrback = expectSync } ) { if (!expectSync) { expect(() => fn.sync(arg)).toThrow(TEST_ERROR); } else if (error) { expect(() => fn.sync(arg)).toThrow(error); } else { expect(fn.sync(arg)).toBe(value); } if (error) { await expect(fn.async(arg)).rejects.toBe(error); } else { await expect(fn.async(arg)).resolves.toBe(value); } await new Promise((resolve, reject) => { let sync = true; fn.errback(arg, (err, val) => { try { expect(err).toBe(error); expect(val).toBe(value); expect(sync).toBe(syncErrback); resolve(); } catch (e) { reject(e); } }); sync = false; }); } describe("gensync({})", () => { describe("option validation", () => { test("disallow async and errback handler together", () => { try { gensync({ sync: throwTestError, async: throwTestError, errback: throwTestError, }); throwTestError(); } catch (err) { expect(err.message).toMatch( /Expected one of either opts.async or opts.errback, but got _both_\./ ); expect(err.code).toBe("GENSYNC_OPTIONS_ERROR"); } }); test("disallow missing sync handler", () => { try { gensync({ async: throwTestError, }); throwTestError(); } catch (err) { expect(err.message).toMatch(/Expected opts.sync to be a function./); expect(err.code).toBe("GENSYNC_OPTIONS_ERROR"); } }); test("errback callback required", () => { const fn = gensync({ sync: throwTestError, async: throwTestError, }); try { fn.errback(); throwTestError(); } catch (err) { expect(err.message).toMatch(/function called without callback/); expect(err.code).toBe("GENSYNC_ERRBACK_NO_CALLBACK"); } }); }); describe("generator function metadata", () => { test("automatic naming", () => { expect( gensync({ sync: function readFileSync() {}, async: () => {}, }).name ).toBe("readFile"); expect( gensync({ sync: function readFile() {}, async: () => {}, }).name ).toBe("readFile"); expect( gensync({ sync: function readFileAsync() {}, async: () => {}, }).name ).toBe("readFileAsync"); expect( gensync({ sync: () => {}, async: function readFileSync() {}, }).name ).toBe("readFileSync"); expect( gensync({ sync: () => {}, async: function readFile() {}, }).name ).toBe("readFile"); expect( gensync({ sync: () => {}, async: function readFileAsync() {}, }).name ).toBe("readFile"); expect( gensync({ sync: () => {}, errback: function readFileSync() {}, }).name ).toBe("readFileSync"); expect( gensync({ sync: () => {}, errback: function readFile() {}, }).name ).toBe("readFile"); expect( gensync({ sync: () => {}, errback: function readFileAsync() {}, }).name ).toBe("readFileAsync"); }); test("explicit naming", () => { expect( gensync({ name: "readFile", sync: () => {}, async: () => {}, }).name ).toBe("readFile"); }); test("default arity", () => { expect( gensync({ sync: function(a, b, c, d, e, f, g) { throwTestError(); }, async: throwTestError, }).length ).toBe(7); }); test("explicit arity", () => { expect( gensync({ arity: 3, sync: throwTestError, async: throwTestError, }).length ).toBe(3); }); }); describe("'sync' handler", async () => { test("success", async () => { const fn = gensync({ sync: (...args) => JSON.stringify(args), }); await expectResult(fn, 42, { value: "[42]", expectSync: true }); }); test("failure", async () => { const fn = gensync({ sync: (...args) => { throw JSON.stringify(args); }, }); await expectResult(fn, 42, { error: "[42]", expectSync: true }); }); }); describe("'async' handler", async () => { test("success", async () => { const fn = gensync({ sync: throwTestError, async: (...args) => Promise.resolve(JSON.stringify(args)), }); await expectResult(fn, 42, { value: "[42]" }); }); test("failure", async () => { const fn = gensync({ sync: throwTestError, async: (...args) => Promise.reject(JSON.stringify(args)), }); await expectResult(fn, 42, { error: "[42]" }); }); }); describe("'errback' sync handler", async () => { test("success", async () => { const fn = gensync({ sync: throwTestError, errback: (...args) => args.pop()(null, JSON.stringify(args)), }); await expectResult(fn, 42, { value: "[42]", syncErrback: true }); }); test("failure", async () => { const fn = gensync({ sync: throwTestError, errback: (...args) => args.pop()(JSON.stringify(args)), }); await expectResult(fn, 42, { error: "[42]", syncErrback: true }); }); }); describe("'errback' async handler", async () => { test("success", async () => { const fn = gensync({ sync: throwTestError, errback: (...args) => process.nextTick(() => args.pop()(null, JSON.stringify(args))), }); await expectResult(fn, 42, { value: "[42]" }); }); test("failure", async () => { const fn = gensync({ sync: throwTestError, errback: (...args) => process.nextTick(() => args.pop()(JSON.stringify(args))), }); await expectResult(fn, 42, { error: "[42]" }); }); }); }); describe("gensync(function* () {})", () => { test("sync throw before body", async () => { const fn = gensync(function*(arg = throwTestError()) {}); await expectResult(fn, undefined, { error: TEST_ERROR, syncErrback: true, }); }); test("sync throw inside body", async () => { const fn = gensync(function*() { throwTestError(); }); await expectResult(fn, undefined, { error: TEST_ERROR, syncErrback: true, }); }); test("async throw inside body", async () => { const fn = gensync(function*() { const val = yield* doSuccess(); throwTestError(); }); await expectResult(fn, undefined, { error: TEST_ERROR, }); }); test("error inside body", async () => { const fn = gensync(function*() { yield* doError(); }); await expectResult(fn, undefined, { error: DID_ERROR, expectSync: true, syncErrback: false, }); }); test("successful return value", async () => { const fn = gensync(function*() { const value = yield* doSuccess(); expect(value).toBe(42); return 84; }); await expectResult(fn, undefined, { value: 84, expectSync: true, syncErrback: false, }); }); test("successful final value", async () => { const fn = gensync(function*() { return 42; }); await expectResult(fn, undefined, { value: 42, expectSync: true, }); }); test("yield unexpected object", async () => { const fn = gensync(function*() { yield {}; }); try { await fn.async(); throwTestError(); } catch (err) { expect(err.message).toMatch( /Got unexpected yielded value in gensync generator/ ); expect(err.code).toBe("GENSYNC_EXPECTED_START"); } }); test("yield suspend yield", async () => { const fn = gensync(function*() { yield Symbol.for("gensync:v1:start"); // Should be "yield*" for no error. yield {}; }); try { await fn.async(); throwTestError(); } catch (err) { expect(err.message).toMatch(/Expected GENSYNC_SUSPEND, got {}/); expect(err.code).toBe("GENSYNC_EXPECTED_SUSPEND"); } }); test("yield suspend return", async () => { const fn = gensync(function*() { yield Symbol.for("gensync:v1:start"); // Should be "yield*" for no error. return {}; }); try { await fn.async(); throwTestError(); } catch (err) { expect(err.message).toMatch(/Unexpected generator completion/); expect(err.code).toBe("GENSYNC_EXPECTED_SUSPEND"); } }); }); describe("gensync.all()", () => { test("success", async () => { const fn = gensync(function*() { const result = yield* gensync.all([doSuccess(), doSuccess()]); expect(result).toEqual([42, 42]); }); await expectResult(fn, undefined, { value: undefined, expectSync: true, syncErrback: false, }); }); test("error first", async () => { const fn = gensync(function*() { yield* gensync.all([doError(), doSuccess()]); }); await expectResult(fn, undefined, { error: DID_ERROR, expectSync: true, syncErrback: false, }); }); test("error last", async () => { const fn = gensync(function*() { yield* gensync.all([doSuccess(), doError()]); }); await expectResult(fn, undefined, { error: DID_ERROR, expectSync: true, syncErrback: false, }); }); test("empty list", async () => { const fn = gensync(function*() { yield* gensync.all([]); }); await expectResult(fn, undefined, { value: undefined, expectSync: true, syncErrback: false, }); }); }); describe("gensync.race()", () => { test("success", async () => { const fn = gensync(function*() { const result = yield* gensync.race([doSuccess(), doError()]); expect(result).toEqual(42); }); await expectResult(fn, undefined, { value: undefined, expectSync: true, syncErrback: false, }); }); test("error", async () => { const fn = gensync(function*() { yield* gensync.race([doError(), doSuccess()]); }); await expectResult(fn, undefined, { error: DID_ERROR, expectSync: true, syncErrback: false, }); }); });
SAVE
CANCEL