Skip to content

Commit 3bc5b7e

Browse files
committed
Add more tests
1 parent 8ceebdf commit 3bc5b7e

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

test/jasmine/tests/plot_api_test.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,6 +3143,70 @@ describe('plot_api helpers', function () {
31433143
)
31443144
).toBe(true);
31453145
});
3146+
3147+
it('Returns false for null values', () => {
3148+
expect(helpers.collectionsAreEqual(null, null)).toBe(false);
3149+
});
3150+
3151+
it('Returns false when comparing null and object', () => {
3152+
expect(helpers.collectionsAreEqual(null, {})).toBe(false);
3153+
});
3154+
3155+
it('Returns true for empty objects', () => {
3156+
expect(helpers.collectionsAreEqual({}, {})).toBe(true);
3157+
});
3158+
3159+
it('Returns true for empty arrays', () => {
3160+
expect(helpers.collectionsAreEqual([], [])).toBe(true);
3161+
});
3162+
3163+
it('Returns false for different array lengths', () => {
3164+
expect(helpers.collectionsAreEqual([1, 2], [1, 2, 3])).toBe(false);
3165+
});
3166+
3167+
it('Handles underscore keys in nested objects', () => {
3168+
expect(
3169+
helpers.collectionsAreEqual(
3170+
{ level1: { _private: 'a', public: 'b' } },
3171+
{ level1: { _private: 'z', public: 'b' } }
3172+
)
3173+
).toBe(true);
3174+
});
3175+
3176+
it('Returns false when comparing undefined and object', () => {
3177+
expect(helpers.collectionsAreEqual(undefined, {})).toBe(false);
3178+
});
3179+
3180+
it('Returns false for objects with different number of keys', () => {
3181+
expect(helpers.collectionsAreEqual({ a: 1, b: 2 }, { a: 1 })).toBe(false);
3182+
});
3183+
3184+
it('Returns false when comparing object and array', () => {
3185+
expect(helpers.collectionsAreEqual({}, [])).toBe(false);
3186+
});
3187+
3188+
it('Handles objects with array values', () => {
3189+
expect(helpers.collectionsAreEqual({ crew: ['Leela', 'Fry'] }, { crew: ['Leela', 'Fry'] })).toBe(true);
3190+
});
3191+
3192+
it('Returns false for objects with different array values', () => {
3193+
expect(helpers.collectionsAreEqual({ crew: ['Leela', 'Fry'] }, { crew: ['Leela', 'Bender'] })).toBe(false);
3194+
});
3195+
3196+
it('Handles arrays with object elements', () => {
3197+
expect(
3198+
helpers.collectionsAreEqual([{ name: 'Leela' }, { name: 'Fry' }], [{ name: 'Leela' }, { name: 'Fry' }])
3199+
).toBe(true);
3200+
});
3201+
3202+
it('Returns false for arrays with different object elements', () => {
3203+
expect(
3204+
helpers.collectionsAreEqual(
3205+
[{ name: 'Leela' }, { name: 'Fry' }],
3206+
[{ name: 'Leela' }, { name: 'Bender' }]
3207+
)
3208+
).toBe(false);
3209+
});
31463210
});
31473211
});
31483212

0 commit comments

Comments
 (0)