From d6a782eeb83fe5def1df65facc9a5d945af9e5fb Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 28 Nov 2022 15:17:08 +0000 Subject: [PATCH] Convert @zooniverse/async-states to ES6 Switch `@zooniverse/async-states` from `require` to static `import` and `export`. --- packages/lib-async-states/package.json | 1 + packages/lib-async-states/src/async-states.js | 2 +- packages/lib-async-states/src/async-states.spec.js | 8 +++----- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/lib-async-states/package.json b/packages/lib-async-states/package.json index 69adbeed97c..f15c3ff2bc8 100644 --- a/packages/lib-async-states/package.json +++ b/packages/lib-async-states/package.json @@ -10,6 +10,7 @@ "bugs": "https://github.com/zooniverse/front-end-monorepo/issues", "version": "0.0.1", "main": "src/async-states.js", + "type": "module", "scripts": { "lint": "zoo-standard src --fix | snazzy", "test": "mocha --config ./test/.mocharc.json \"./src/async-states.spec.js\"", diff --git a/packages/lib-async-states/src/async-states.js b/packages/lib-async-states/src/async-states.js index 21ab9bb43ca..2e96d44f44a 100644 --- a/packages/lib-async-states/src/async-states.js +++ b/packages/lib-async-states/src/async-states.js @@ -41,4 +41,4 @@ Object.defineProperty(asyncStates, 'values', { value: Object.values(asyncStates) }) -module.exports = asyncStates +export default asyncStates diff --git a/packages/lib-async-states/src/async-states.spec.js b/packages/lib-async-states/src/async-states.spec.js index bd217694dff..57271375b22 100644 --- a/packages/lib-async-states/src/async-states.spec.js +++ b/packages/lib-async-states/src/async-states.spec.js @@ -1,4 +1,4 @@ -const asyncStates = require('./async-states') +import asyncStates from './async-states.js' describe('asyncStates', function () { const states = [ @@ -17,8 +17,7 @@ describe('asyncStates', function () { }) it('should be immutable', function () { - asyncStates[state] = 'foobar' - expect(asyncStates[state]).to.equal(state) + expect(() => asyncStates[state] = 'foobar').to.throw() }) }) }) @@ -29,8 +28,7 @@ describe('asyncStates', function () { }) it('should be immutable', function () { - asyncStates.values = 'foobar' - expect(asyncStates.values).to.deep.equal(states) + expect(() => asyncStates.values = 'foobar').to.throw() }) }) })