Skip to content

Commit

Permalink
Merge pull request #22 from fink-lang/fix-import-detection
Browse files Browse the repository at this point in the history
fix(jest-wrapper): fix import detections
  • Loading branch information
kollhof authored Oct 5, 2020
2 parents 93e4e97 + 7321060 commit 291a880
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/transform.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

{parse} = import '@fink/larix'
{generate} = import '@fink/loxia'
{starts_with} = import '@fink/std-lib/str'
{set_props, new} = import '@fink/js-interop/reflect'
{SyntaxError} = import '@fink/js-interop/globals'

Expand Down Expand Up @@ -30,7 +31,7 @@ module_scope = fn scope:

is_import_from_fink_jest = fn init:
match init:
{callee: {name: 'require'}, arguments: [{value: '@fink/jest'}]}:
{callee: {name: 'require'}, arguments: [{value: starts_with ?, '@fink/jest/'}]}:
true
else:
false
Expand Down
2 changes: 1 addition & 1 deletion src/transform.test.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe process, fn:
it 'transforms mock imported from @fink/jest as jest.mock', fn:
{code, map} = process
"
{it, mock, mock_fn, require_actual} = import '@fink/jest'
{it, mock, mock_fn, require_actual} = import '@fink/jest/test.fnk'

mock './transform.fnk', fn: dict:
foobar: mock_fn _
Expand Down
6 changes: 3 additions & 3 deletions src/transform.test.fnk.snap
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Object {
mock,
mock_fn,
require_actual
} = require(\\"@fink/jest\\");
} = require(\\"@fink/jest/test.js\\");
/* istanbul ignore next */
jest.mock(\`./transform.fnk\`, () => ({
Expand All @@ -217,13 +217,13 @@ const foo = mock => mock(\`not jest.mock\`);
exports.foo = foo;",
"map": Object {
"mappings": ";AAAC,EAAA,E;AAAI,EAAA,I;AAAM,EAAA,O;AAAS,EAAA;YAAyB,Y;;AAE7C;AAAA,UAAI,iBAAJ,EAAwB,OAAI;AAC1B,YAAQ,OADkB,EAAA;AAE1B;AAAO;AAAA,qBAAc,aAAd;AAFmB,CAAJ,CAAxB;;AAIA,MAAA,GAAG,GAAG,IAAA,IACJ,IAAI,CADN,eACM,CADN;;QAAA,G,GAAA,G",
"mappings": ";AAAC,EAAA,E;AAAI,EAAA,I;AAAM,EAAA,O;AAAS,EAAA;YAAyB,oB;;AAE7C;AAAA,UAAI,iBAAJ,EAAwB,OAAI;AAC1B,YAAQ,OADkB,EAAA;AAE1B;AAAO;AAAA,qBAAc,aAAd;AAFmB,CAAJ,CAAxB;;AAIA,MAAA,GAAG,GAAG,IAAA,IACJ,IAAI,CADN,eACM,CADN;;QAAA,G,GAAA,G",
"names": Array [],
"sources": Array [
"/temp/src/foobar.fnk",
],
"sourcesContent": Array [
"{it, mock, mock_fn, require_actual} = import '@fink/jest'
"{it, mock, mock_fn, require_actual} = import '@fink/jest/test.fnk'
mock './transform.fnk', fn: dict:
foobar: mock_fn _
Expand Down

0 comments on commit 291a880

Please sign in to comment.