From 6eccb0ea6cfac169ac7f75dae9e4b30a59885a13 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Fri, 21 Jan 2022 10:05:04 -0800 Subject: [PATCH] Simplified tests code --- .../unit/serializers/host-catalog-test.js | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/addons/api/tests/unit/serializers/host-catalog-test.js b/addons/api/tests/unit/serializers/host-catalog-test.js index 8b076860b..df3f8efc8 100644 --- a/addons/api/tests/unit/serializers/host-catalog-test.js +++ b/addons/api/tests/unit/serializers/host-catalog-test.js @@ -6,44 +6,38 @@ module('Unit | Serializer | host catalog', function (hooks) { // Replace this with your real tests. test('it exists', function (assert) { - let store = this.owner.lookup('service:store'); - let serializer = store.serializerFor('host-catalog'); + const store = this.owner.lookup('service:store'); + const serializer = store.serializerFor('host-catalog'); assert.ok(serializer); }); test('it serializes records', function (assert) { - let store = this.owner.lookup('service:store'); - let record = store.createRecord('host-catalog', {}); + const store = this.owner.lookup('service:store'); + const record = store.createRecord('host-catalog', {}); - let serializedRecord = record.serialize(); - - assert.ok(serializedRecord); + assert.ok(record.serialize()); }); test('it serializes a static host-catalog as expected', async function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); - const serializer = store.serializerFor('host-catalog'); const record = store.createRecord('host-catalog', { name: 'static', description: 'this is a static host-catalog', type: 'static', }); - const snapshot = record._createSnapshot(); - const serializedRecord = serializer.serialize(snapshot); const expectedResult = { name: 'static', description: 'this is a static host-catalog', type: 'static', }; - assert.deepEqual(serializedRecord, expectedResult); + assert.deepEqual(record.serialize(), expectedResult); }); test('it serializes an AWS plugin as expected, ignoring Azure fields', async function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); - const serializer = store.serializerFor('host-catalog'); const record = store.createRecord('host-catalog', { compositeType: 'aws', name: 'AWS', @@ -60,8 +54,6 @@ module('Unit | Serializer | host catalog', function (hooks) { secret_id: 'a1b2c3', secret_value: 'a1b2c3', }); - const snapshot = record._createSnapshot(); - const serializedRecord = serializer.serialize(snapshot); const expectedResult = { name: 'AWS', description: 'this is a Aws plugin host-catalog', @@ -73,13 +65,12 @@ module('Unit | Serializer | host catalog', function (hooks) { secret_access_key: 'testing', }, }; - assert.deepEqual(serializedRecord, expectedResult); + assert.deepEqual(record.serialize(), expectedResult); }); test('it serializes an Azure plugin as expected, ignoring AWS fields', async function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); - const serializer = store.serializerFor('host-catalog'); const record = store.createRecord('host-catalog', { compositeType: 'azure', name: 'Azure', @@ -96,8 +87,6 @@ module('Unit | Serializer | host catalog', function (hooks) { secret_id: 'a1b2c3', secret_value: 'a1b2c3', }); - const snapshot = record._createSnapshot(); - const serializedRecord = serializer.serialize(snapshot); const expectedResult = { name: 'Azure', description: 'this is a Azure plugin host-catalog', @@ -111,13 +100,12 @@ module('Unit | Serializer | host catalog', function (hooks) { secret_value: 'a1b2c3', }, }; - assert.deepEqual(serializedRecord, expectedResult); + assert.deepEqual(record.serialize(), expectedResult); }); test('it serializes aws correctly on update', function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); - const serializer = store.serializerFor('host-catalog'); store.push({ data: { id: '1', @@ -136,7 +124,6 @@ module('Unit | Serializer | host catalog', function (hooks) { }, }); const record = store.peekRecord('host-catalog', '1'); - const snapshot = record._createSnapshot(); const expectedResult = { type: 'plugin', name: 'aws', @@ -148,14 +135,12 @@ module('Unit | Serializer | host catalog', function (hooks) { secret_access_key: 'testing', }, }; - const serializedRecord = serializer.serialize(snapshot); - assert.deepEqual(serializedRecord, expectedResult); + assert.deepEqual(record.serialize(), expectedResult); }); test('it serializes azure correctly on update', function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); - const serializer = store.serializerFor('host-catalog'); store.push({ data: { id: '2', @@ -176,7 +161,6 @@ module('Unit | Serializer | host catalog', function (hooks) { }, }); const record = store.peekRecord('host-catalog', '2'); - const snapshot = record._createSnapshot(); const expectedResult = { type: 'plugin', name: 'azure', @@ -190,7 +174,6 @@ module('Unit | Serializer | host catalog', function (hooks) { secret_value: 'secretValue21', }, }; - const serializedRecord = serializer.serialize(snapshot); - assert.deepEqual(serializedRecord, expectedResult); + assert.deepEqual(record.serialize(), expectedResult); }); });