#lang scheme/base

(require scheme/match

(define-runtime-path here ".")
(define t1:script #f)

(define/provide-test-suite module-tests

  ;; Dynamically requiring the module here makes
  ;; this test immune to the effects of other tests that may
  ;; play around with the registry. If we statically
  ;; required, another test suite might clear the
  ;; registry before we get run.
  #:before (lambda ()
             (set! t1:script (dynamic-require (build-path here "") 'script)))
   "module exports correct script binding"
   (check-equal? t1:script
                 (js (function dave (a b) (+ a b))
                     (function noel (a b) (/ a b)))))

   "registry contains module's script"
    (regexp-quote (javascript->string t1:script))

   "registry contains dependency's script"
   (match (regexp-match-positions
           (regexp-quote (javascript->string t1:script))
          [(list (cons start end))
           (check > start 0)]
          [_ (fail "Registry does not contain script")])))