File: package.coffee

package info (click to toggle)
coffeescript 2.7.0%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,360 kB
  • sloc: makefile: 20; xml: 9; sh: 6; javascript: 5
file content (27 lines) | stat: -rw-r--r-- 994 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
return if window? or testingBrowser?

{EventEmitter}  = require 'events'
{join}          = require 'path'
{cwd}           = require 'process'
{pathToFileURL} = require 'url'


packageEntryPath = join cwd(), 'lib/coffeescript/index.js'
packageEntryUrl  = pathToFileURL packageEntryPath


test "the coffeescript package exposes all members as named exports in Node", ->

  requiredPackage = require packageEntryPath
  requiredKeys = Object.keys requiredPackage

  importedPackage = await import(packageEntryUrl)
  importedKeys = new Set Object.keys(importedPackage)

  # In `command.coffee`, CoffeeScript extends a `new EventEmitter`;
  # we want to ignore these additional added keys.
  eventEmitterKeys = new Set Object.getOwnPropertyNames(Object.getPrototypeOf(new EventEmitter))

  for key in requiredKeys when not eventEmitterKeys.has(key)
    # Use `eq` test so that missing keys have their names printed in the error message.
    eq (if importedKeys.has(key) then key else undefined), key