Skip to content
Assertion library for Google Apps Script
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.clasp.json
.eslintrc.json
.gitignore
README.md
package-lock.json
package.json
tsconfig.json

README.md

clasp 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

You can’t perform that action at this time.