v.0.6.3
Minor Patch: v0.6.3
This patch introduces a small quality of life improvement, which I felt was particularly necessary after introducing class-based testing:
Multiline Test Cases!
/**
* @test 'Jesse', 24
* ~> $.grow(3)
* ~> $.grow(2) returns 29
*
* @test 'Rick', 62
* ~> $.grow(1) returns 63
* ~> $.grow(2) returns 65
* ~> $.getName() returns 'Rick'
* ~> $.grow() returns $.age === 66
*/
export class Person {
constructor(name, age) {
this.name = name
this.age = age
}
grow(amount = 1) {
return this.age += amount
}
getName() {
return this.name
}
}
If you write a test case on multiple lines, Pineapple will now automatically concatenate it to the test case. This is not exclusive to class / higher-order function syntax.
/**
* @test {
* tenant: 'Rick',
* length: 10,
* type: 'boat'
* } resolves
*
* @test {
* tenant: 10,
* length: 'Rick',
* type: 'boat'
* } rejects
*/
export async function createLease({ tenant, length, type = 'boat' }) {
if (typeof tenant !== 'string' || typeof length !== 'number')
throw new Error('Types do not match.')
return { type, tenant, length }
}