diff --git a/__snapshots__/e2e_spec.js b/__snapshots__/e2e_spec.js index da1124a..863ef64 100644 --- a/__snapshots__/e2e_spec.js +++ b/__snapshots__/e2e_spec.js @@ -14,41 +14,6 @@ it('is a test', function () { ` -exports['math default exports'] = ` -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i { return bundle('math_spec.js').then((output) => { // check that bundled tests work eval(output) - snapshot('math default exports', output) }) }) + it('named ES6', () => { + return bundle('divide_spec.js').then((output) => { + // check that bundled tests work + eval(output) + }) + }) + + it('handles module.exports and import', () => { return bundle('sub_spec.js').then((output) => { // check that bundled tests work @@ -60,4 +67,11 @@ describe('imports and exports', () => { // so as long as eval works, do not snapshot it }) }) + + it('handles default string import', () => { + return bundle('dom_spec.js').then((output) => { + // check that bundled tests work + eval(output) + }) + }) }) diff --git a/test/fixtures/divide.js b/test/fixtures/divide.js new file mode 100644 index 0000000..c6b2e1b --- /dev/null +++ b/test/fixtures/divide.js @@ -0,0 +1,2 @@ +// named export +export const divide = (a, b) => a/b diff --git a/test/fixtures/divide_spec.js b/test/fixtures/divide_spec.js new file mode 100644 index 0000000..fe24d1b --- /dev/null +++ b/test/fixtures/divide_spec.js @@ -0,0 +1,8 @@ +import { divide } from './divide' + +context('ES6 named export and import', function () { + it('works', () => { + expect(divide, 'divide').to.be.a('function') + expect(divide(10, 2)).to.eq(5) + }) +}) diff --git a/test/fixtures/dom.js b/test/fixtures/dom.js new file mode 100644 index 0000000..74486ae --- /dev/null +++ b/test/fixtures/dom.js @@ -0,0 +1 @@ +export default 'dom' diff --git a/test/fixtures/dom_spec.js b/test/fixtures/dom_spec.js new file mode 100644 index 0000000..f7bb120 --- /dev/null +++ b/test/fixtures/dom_spec.js @@ -0,0 +1,8 @@ +const dom = require('./dom').default + +context('imports default string', function () { + it('works', () => { + expect(dom, 'dom').to.be.a('string') + expect(dom).to.equal('dom') + }) +}) diff --git a/test/fixtures/math_spec.js b/test/fixtures/math_spec.js index 1443cf3..a48b68d 100644 --- a/test/fixtures/math_spec.js +++ b/test/fixtures/math_spec.js @@ -1,4 +1,7 @@ -import { add } from './math' +// math exports default object +// so if we want a property, first we need to grab the default +import math from './math' +const {add} = math context('math.js', function () { it('imports function', () => {