From e293acc78d7cf7287bb1e592f0ec20739347faaa Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Tue, 21 Mar 2017 16:53:40 -0700 Subject: [PATCH] Add remove and add rp tests --- ui/spec/admin/reducers/adminSpec.js | 35 +++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/ui/spec/admin/reducers/adminSpec.js b/ui/spec/admin/reducers/adminSpec.js index 963833940f..ff15d75529 100644 --- a/ui/spec/admin/reducers/adminSpec.js +++ b/ui/spec/admin/reducers/adminSpec.js @@ -4,6 +4,7 @@ import { addUser, addRole, addDatabase, + addRetentionPolicy, syncUser, syncRole, editUser, @@ -14,6 +15,7 @@ import { deleteRole, deleteUser, removeDatabase, + removeRetentionPolicy, filterRoles, filterUsers, addDatabaseDeleteCode, @@ -114,10 +116,18 @@ const scoped = {scope: 'db1', allowed: ['p1', 'p3']} const permissions = [global, scoped] // Databases && Retention Policies +const rp1 = { + name: 'rp1', + duration: '0', + replication: 2, + isDefault: true, + links: {self: '/chronograf/v1/sources/1/db/db1/rp/rp1'}, +} + const db1 = { name: 'db1', links: {self: '/chronograf/v1/sources/1/db/db1'}, - retentionPolicies: [], + retentionPolicies: [rp1], } const db2 = { @@ -128,7 +138,7 @@ const db2 = { } describe('Admin.Reducers', () => { - describe('Databases and Retention Policies', () => { + describe('Databases', () => { const state = {databases: [db1, db2]} it('can add a database', () => { @@ -177,7 +187,28 @@ describe('Admin.Reducers', () => { expect(actual.databases).to.deep.equal(expected) }) + }) + describe('Retention Policies', () => { + const state = {databases: [db1]} + + it('can add a retention policy', () => { + const actual = reducer(state, addRetentionPolicy(db1)) + const expected = [ + {...db1, retentionPolicies: [NEW_EMPTY_RP, rp1]}, + ] + + expect(actual.databases).to.deep.equal(expected) + }) + + it('can remove a retention policy', () => { + const actual = reducer(state, removeRetentionPolicy(db1, rp1)) + const expected = [ + {...db1, retentionPolicies: []}, + ] + + expect(actual.databases).to.deep.equal(expected) + }) }) it('it can add a user', () => {