UNPKG

@gameroom/kit

Version:

Node kit for the Gameroom API

52 lines (47 loc) 1.24 kB
const chai = require('chai') const { models: { Product, Price } } = require('../../') const should = chai.should() // const abortTest = (Storable) => // new Promise((resolve, reject) => { // Storable.get().then(resolve).catch(reject) // Storable.controller.abort() // }) describe('Base', () => { describe('Storable.abort()', () => { it('should abort storable fetch', async () => { let result, error const test = () => new Promise((resolve, reject) => { Product.get().then(resolve).catch(reject) Product.abort() }) try { result = await test() } catch (err) { error = err } should.not.exist(result) should.exist(error) should.equal(error.message, 'canceled') }) }) describe('Storable.abort()', () => { it('should not abort other storable fetches', async () => { let result, error const test = () => new Promise((resolve, reject) => { Price.get().then(resolve).catch(reject) Product.abort() }) try { result = await test() } catch (err) { error = err } should.exist(result) should.not.exist(error) }) }) })