Skip to content

Commit

Permalink
array set test (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer authored Oct 26, 2019
1 parent bcacb71 commit ca12aa9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/unit/changeset-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { isPresent, typeOf } from '@ember/utils';
import { run, next } from '@ember/runloop';

let dummyModel;
let exampleArray = [];
let dummyValidations = {
name(value) {
return isPresent(value) && value.length > 3 || 'too short';
Expand Down Expand Up @@ -55,7 +56,7 @@ module('Unit | Utility | changeset', function(hooks) {
return resolve(this);
}
});
dummyModel = Dummy.create();
dummyModel = Dummy.create({ exampleArray });
});

/**
Expand Down Expand Up @@ -108,6 +109,15 @@ module('Unit | Utility | changeset', function(hooks) {
);
});

test('#change works with arrays', function(assert) {
let dummyChangeset = new Changeset(dummyModel);
const newArray = [...exampleArray, 'new'];
let expectedResult = { exampleArray: newArray }
dummyChangeset.set('exampleArray', newArray);

assert.deepEqual(get(dummyChangeset, 'change'), expectedResult, 'should return changes object');
});

/**
* #errors
*/
Expand Down

0 comments on commit ca12aa9

Please sign in to comment.