Created
July 4, 2018 11:35
-
-
Save asiniy/eb3b7943fca2d5f2fe7e68f367d83f9c to your computer and use it in GitHub Desktop.
index.spec.ts // Extending JavaScript with ease (beginner level tutorial)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tslint:disable:no-expression-statement | |
import { test } from 'ava'; | |
import objectFetch from './index'; | |
const object = { a: 'b' }; | |
test('returns key if it exists', t => { | |
t.is(objectFetch(object, 'a'), 'b'); | |
}); | |
test('throws if there is no key', async t => { | |
const error = await t.throws(() => { | |
objectFetch(object, 'c'); | |
}); | |
t.is(error.name, 'ReferenceError'); | |
t.is(error.message, 'No such property: c'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment