github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/ui-v2/tests/unit/helpers/policy/datacenters-test.js (about) 1 import { datacenters } from 'consul-ui/helpers/policy/datacenters'; 2 import { module, test } from 'qunit'; 3 4 module('Unit | Helper | policy/datacenters'); 5 6 test('it returns "All" if you pass a policy with no Datacenters property', function(assert) { 7 const expected = ['All']; 8 const actual = datacenters([{}]); 9 assert.deepEqual(actual, expected); 10 }); 11 test('it returns "All" if you pass a policy with an empty Array as its Datacenters property', function(assert) { 12 const expected = ['All']; 13 const actual = datacenters([{ Datacenters: [] }]); 14 assert.deepEqual(actual, expected); 15 }); 16 test('it returns "All" if you pass a policy with anything but an array', function(assert) { 17 // we know this uses isArray so lets just test with null as thats slightly likely 18 const expected = ['All']; 19 const actual = datacenters([{ Datacenters: null }]); 20 assert.deepEqual(actual, expected); 21 }); 22 test('it returns the Datacenters if you pass a policy with correctly set Datacenters', function(assert) { 23 const expected = ['dc-1', 'dc-2']; 24 const actual = datacenters([{ Datacenters: ['dc-1', 'dc-2'] }]); 25 assert.deepEqual(actual, expected); 26 });