From 057ccd09e6d021ceceb8899958979004eae87fd2 Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Thu, 8 Dec 2016 15:18:39 -0500 Subject: [PATCH] Add unit test for select-values - Add unit test for select-values Test aligns with current behavior if non-array value is passed in as the first argument. --- tests/unit/utils/select-values-test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/unit/utils/select-values-test.js diff --git a/tests/unit/utils/select-values-test.js b/tests/unit/utils/select-values-test.js new file mode 100644 index 0000000000..afe4989cfd --- /dev/null +++ b/tests/unit/utils/select-values-test.js @@ -0,0 +1,24 @@ +import SelectValues from 'hospitalrun/utils/select-values'; +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('util:select-values', 'Unit | Utils | select-values'); + +test('selectValues', function(assert) { + assert.deepEqual( + SelectValues.selectValues(['a', 'b']), + [{ id: 'a', value: 'a' }, { id: 'b', value: 'b' }], + 'Should add id to values' + ); + + assert.deepEqual( + SelectValues.selectValues(['a', 'b'], true), + [{ id: '', value: '' }, { id: 'a', value: 'a' }, { id: 'b', value: 'b' }], + 'Should add empty' + ); + + assert.deepEqual( + SelectValues.selectValues('test'), + undefined, + 'Should return undefined if non array' + ); +});