From 2219136c51c16853a4375acbac8db11399232532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Sun, 28 Jan 2024 16:28:06 +0100 Subject: [PATCH] Add "should" style tests for `iterable` --- test/should.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/should.js b/test/should.js index 3ac3b2b5..323b98c5 100644 --- a/test/should.js +++ b/test/should.js @@ -2942,6 +2942,28 @@ describe('should', function() { }, 'expected [ { a: 1 }, { b: 2 }, { c: 3 } ] to not be an ordered superset of [ { a: 1 }, { b: 2 } ]'); }); + it ('iterable', function() { + ([1, 2, 3]).should.be.iterable; + (new Map([[1, 'one'], [2, 'two'], [3, 'three']])).should.be.iterable; + (new Set([1, 2, 3])).should.be.iterable; + + err(function() { + (42).should.be.iterable; + }, 'expected 42 to be an iterable'); + + err(function() { + ('hello').should.be.iterable; + }, "expected 'hello' to be an iterable"); + + err(function() { + (true).should.be.iterable; + }, 'expected true to be an iterable'); + + err(function() { + ({ key: 'value' }).should.be.iterable; + }, 'expected { key: \'value\' } to be an iterable'); + }) + it('change', function() { var obj = { value: 10, str: 'foo' }, heroes = ['spiderman', 'superman'],