From 7edb465f3a208d0a91d42d33e111382cb2f90380 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 27 Aug 2022 21:33:18 -0700 Subject: [PATCH] update README example --- .eslintrc.json | 1 + README.md | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 54b2c128..6e3f395c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,6 @@ { "plugins": [], + "ignorePatterns": ["dist"], "extends": [ "eslint:recommended", "plugin:markdown/recommended" diff --git a/README.md b/README.md index 3d3ccb9b..a73ab6d0 100644 --- a/README.md +++ b/README.md @@ -53,17 +53,20 @@ import test from 'node:test' import assert from 'node:assert/strict' import esmock from 'esmock' -test('should mock local files and packages', async () => { - const stringy = await esmock('../src/stringy.js', { - stringifierpackage: JSON.stringify, - '#icons': { kasa: 'β˜‚' }, - '../src/hello.js': { - default: () => 'world', - exportedFunction: () => ({ icon: 'kasa' }) +test('should mock packages and local files', async () => { + const cookup = await esmock('../src/cookup.js', { + addpkg: (a, b) => a + b, + '#icon': { + coffee: 'β˜•', + bacon: 'πŸ₯“' + }, + '../src/breakfast.js': { + default: () => ['coffee', 'bacon'], + addSalt: meal => meal + 'πŸ§‚' } }) - assert.strictEqual(stringy(), JSON.stringify({ kasa: 'world β˜‚' })) + assert.strictEqual(cookup('breakfast'), 'β˜•πŸ₯“πŸ§‚') }) test('should do global instance mocks β€”third param', async () => { @@ -84,7 +87,7 @@ test('should mock "await import()" using esmock.p', async () => { // mock definition is returned from cache, when import is called assert.strictEqual(await doAwaitImport('cfg'), 'cfg') - // a bit more info are found in the descriptive guide + // a bit more info are found in the wiki guide }) // a "partial mock" merges the new and original definitions