From 543d5f06193b3c4bdbea6b7b16e8406b66e587d8 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Tue, 9 Aug 2022 23:07:24 +0200 Subject: [PATCH] test with evalScope instead of extend --- packages/eval/test/evaluate.test.mjs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/eval/test/evaluate.test.mjs b/packages/eval/test/evaluate.test.mjs index c0853045..4fc2f8a9 100644 --- a/packages/eval/test/evaluate.test.mjs +++ b/packages/eval/test/evaluate.test.mjs @@ -4,18 +4,16 @@ Copyright (C) 2022 Strudel contributors - see . */ -import { describe, it, expect } from 'vitest'; +import { expect, describe, it, beforeAll } from 'vitest'; -import { evaluate, extend, evalScope } from '../evaluate.mjs'; +import { evaluate, evalScope } from '../evaluate.mjs'; import { mini } from '@strudel.cycles/mini'; import * as strudel from '@strudel.cycles/core'; -const { fastcat, cat, slowcat, reify } = strudel; +const { fastcat } = strudel; -extend({ mini, cat, fastcat, slowcat, reify }); -// Object.assign(globalThis, strudel); -// extend({ mini }, s); // TODO: this is not working -// TODO: test evalScope -// evalScope({ mini }, strudel); +beforeAll(async () => { + evalScope({ mini }, strudel); +}); describe('evaluate', () => { const ev = async (code) => (await evaluate(code)).pattern._firstCycleValues; @@ -25,8 +23,8 @@ describe('evaluate', () => { expect(await ev('fastcat("c3", "d3")')).toEqual(['c3', 'd3']); expect(await ev('slowcat("c3", "d3")')).toEqual(['c3']); }); - it('Should be extendable', async () => { - extend({ myFunction: (...x) => fastcat(...x) }); + it('Scope should be extendable', async () => { + await evalScope({ myFunction: (...x) => fastcat(...x) }); expect(await ev('myFunction("c3", "d3")')).toEqual(['c3', 'd3']); }); it('Should evaluate simple double quoted mini notation', async () => {