Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.
/ AssertGAS Public archive

Assertion library for Google Apps Script

Notifications You must be signed in to change notification settings

gasunit/AssertGAS

Repository files navigation

clasp tested by ts-mocha JavaScript Style Guide

AssertGAS

Assertion library for Google Apps Script. Compatible with GASUnit.

Usage

Add library

project key: MWRSRXxKQuT_xRUeAjNzn4TVZgzu5bsVr

Write tests

var exports = GASUnit.exports
var assertThat = AssertGAS.assertThat

function test_array () {
  exports({
    'Array': {
      '#indexOf()': {
        'should return -1 when not present': function () {
          var index = [1, 2, 3].indexOf(4)
          assertThat(index).is(-1)
        },
        'should return the index when present': function () {
          var index = [1, 2, 3].indexOf(3)
          assertThat(index).is(2)
        }
      }
    }
  })
}

API

API is inspired by AssertJ.

matches(callback)

assertThat('foo').matches(function (value) {
  return value.startsWith('f')
})

doesNotMatch(callback)

assertThat('bar').doesNotMatch(function (value) {
  return value.startsWith('f')
})

is(expected)

assertThat('foo').is('foo')

isNot(expected)

assertThat('foo').isNot('bar')

isNull()

assertThat(null).isNull()

isNotNull()

assertThat(undefined).isNotNull()

isUndefined()

assertThat(undefined).isUndefined()

isNotUndefined()

assertThat(null).isNotUndefined()

isTrue()

assertThat(true).isTrue()

isFalse()

assertThat(false).isFalse()

Development

See package.json