diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-03-27 12:47:04 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-03-27 12:47:04 -0300 |
commit | c6f1011722dc6fe50afb3a63ee414c70dbfd6abf (patch) | |
tree | d13235a4b37e8264a1fbccdfad12009f7a3a4f6d /test/unit/content/dependencies | |
parent | cb13d591c6965dc52d89ec4d1e10558e6b22456b (diff) |
data steps: basic custom mocking function support
I checked out a few libraries but none really behaved the way I needed, and coding it myself means much lower- level access, which makes certain options a lot easier (e.g. excluding one argument of a mocked function from assertion while matching the rest against a pattern).
Diffstat (limited to 'test/unit/content/dependencies')
-rw-r--r-- | test/unit/content/dependencies/linkArtist.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/unit/content/dependencies/linkArtist.js b/test/unit/content/dependencies/linkArtist.js new file mode 100644 index 00000000..6d9e637d --- /dev/null +++ b/test/unit/content/dependencies/linkArtist.js @@ -0,0 +1,31 @@ +import t from 'tap'; +import {testContentFunctions} from '../../../lib/content-function.js'; + +testContentFunctions(t, 'linkArtist', async (t, evaluate) => { + const artistObject = {}; + const linkTemplate = {}; + + await evaluate.load({ + mock: evaluate.mock(mock => ({ + linkThing: { + relations: mock.function('linkThing.relations', () => ({})) + .args([undefined, 'localized.artist', artistObject]) + .once(), + + data: mock.function('linkThing.data', () => ({})) + .args(['localized.artist', artistObject]) + .once(), + + generate: mock.function('linkThing.data', () => linkTemplate) + .once(), + } + })), + }); + + const result = evaluate({ + name: 'linkArtist', + args: [artistObject], + }); + + t.equal(result, linkTemplate); +}); |