3 const assert = require('assert');
4 const calculateFavouriteUpdates = require('../lib/calculate-favourite-updates');
6 describe('calculateFavouriteUpdates', () => {
7 it('updates for subsequent favourites', () => {
8 const roomIdFavouritePositionPairs = [
9 ['1bc06a50d850640967290b2f', 19],
10 ['2bc06a50d850640967290b2f', 20],
11 ['3bc06a50d850640967290b2f', 21]
14 const updates = calculateFavouriteUpdates(
15 '9bc06a50d850640967290b2f',
17 roomIdFavouritePositionPairs
20 assert.deepEqual(updates, [['2bc06a50d850640967290b2f', 21], ['3bc06a50d850640967290b2f', 22]]);
23 it('ignores non-number favourite', () => {
24 const roomIdFavouritePositionPairs = [
25 ['1bc06a50d850640967290b2f', 0],
26 ['2bc06a50d850640967290b2f', undefined],
27 ['3bc06a50d850640967290b2f', 19],
28 ['4bc06a50d850640967290b2f', 20],
29 ['5bc06a50d850640967290b2f', null],
30 ['6bc06a50d850640967290b2f', 21],
31 ['7bc06a50d850640967290b2f', false]
34 const updates = calculateFavouriteUpdates(
35 '9bc06a50d850640967290b2f',
37 roomIdFavouritePositionPairs
40 assert.deepEqual(updates, [['4bc06a50d850640967290b2f', 21], ['6bc06a50d850640967290b2f', 22]]);