From 62b4e71687ef171b4863c12883575ee070865ad6 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Tue, 15 Sep 2020 11:13:17 -0400 Subject: [PATCH] test: Update account serializer test for 'serializePassword' --- .../tests/unit/serializers/account-test.js | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/addons/api/tests/unit/serializers/account-test.js b/addons/api/tests/unit/serializers/account-test.js index 6906c458d..77b6d19d3 100644 --- a/addons/api/tests/unit/serializers/account-test.js +++ b/addons/api/tests/unit/serializers/account-test.js @@ -4,14 +4,6 @@ import { setupTest } from 'ember-qunit'; module('Unit | Serializer | account', function(hooks) { setupTest(hooks); - // Replace this with your real tests. - test('it exists', function(assert) { - let store = this.owner.lookup('service:store'); - let serializer = store.serializerFor('account'); - - assert.ok(serializer); - }); - test('it serializes records', function(assert) { let store = this.owner.lookup('service:store'); let record = store.createRecord('account', {}); @@ -20,4 +12,29 @@ module('Unit | Serializer | account', function(hooks) { assert.ok(serializedRecord); }); + + test('it serializes only password when `adapterOptions.serializePassword` is true', function (assert) { + assert.expect(1); + const store = this.owner.lookup('service:store'); + const serializer = store.serializerFor('account'); + const record = store.createRecord('account', { + type: 'password', + name: 'Name', + description: 'Description', + attributes: { + login_name: 'Login Name', + password: 'Password' + }, + version: 1 + }); + const snapshot = record._createSnapshot(); + snapshot.adapterOptions = { + serializePassword: true + }; + const serializedRecord = serializer.serialize(snapshot); + assert.deepEqual(serializedRecord, { + password: 'Password', + version: 1 + }); + }); });