From a0d8d090030329048fba93eae06243e5475967e6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 27 Nov 2017 07:50:33 -0500 Subject: [PATCH] guard against introducing ES6+isms into store.js --- test/store/index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/store/index.js b/test/store/index.js index fabaa64c4b..f8467e9e89 100644 --- a/test/store/index.js +++ b/test/store/index.js @@ -1,7 +1,27 @@ +import fs from 'fs'; import assert from 'assert'; +import MagicString from 'magic-string'; +import { parse } from 'acorn'; import { Store } from '../../store.js'; describe('store', () => { + it('is written in ES5', () => { + const source = fs.readFileSync('store.js', 'utf-8'); + + const ast = parse(source, { + sourceType: 'module' + }); + + const magicString = new MagicString(source); + ast.body.forEach(node => { + if (/^(Im|Ex)port/.test(node.type)) magicString.remove(node.start, node.end); + }); + + parse(magicString.toString(), { + ecmaVersion: 5 + }); + }); + describe('get', () => { it('gets a specific key', () => { const store = new Store({