From 2cb4ed7e80f2650821510eb1b00bc9098be0b926 Mon Sep 17 00:00:00 2001 From: Adarsh Dubey Date: Mon, 4 Mar 2024 17:52:51 +0530 Subject: [PATCH] fix(HMS-3593): Added unit test cases for instance type selection --- .../InstanceTypesSelect.test.js | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js b/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js index 43f93998..ce2542b8 100644 --- a/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js +++ b/src/Components/InstanceTypesSelect/InstanceTypesSelect.test.js @@ -49,13 +49,35 @@ describe('InstanceTypesSelect x86_64', () => { const items = await screen.findAllByLabelText(/^Instance Type/); expect(items).toHaveLength(1); }); - test('filter with a query', async () => { - const query = 'vcpus > 2 and cores > 2'; + test('filter with a query greater than', async () => { + const query = 'vcpus > 2 and cores > 2 and memory > 1024'; const dropdown = await mountSelectAndClick(); await userEvent.type(dropdown, query); const items = await screen.findAllByLabelText(/^Instance Type/); expect(items).toHaveLength(1); }); + test('filter with a query less than', async () => { + const query = 'vcpus < 2 and cores < 2 and memory < 1024'; + const dropdown = await mountSelectAndClick(); + await userEvent.type(dropdown, query); + const items = await screen.findAllByLabelText(/^Instance Type/); + expect(items).toHaveLength(1); + }); + test('filter with a query combination', async () => { + const query = 'vcpus < 3 and cores > 1 and memory = 1024'; + const dropdown = await mountSelectAndClick(); + await userEvent.type(dropdown, query); + const input = await screen.findByLabelText('Selected instance type'); + expect(input).toBeInTheDocument(); + }); + test('filter with a query equal', async () => { + const query = 'vcpus = 2 and cores = 2 and memory = 1024'; + const dropdown = await mountSelectAndClick(); + await userEvent.type(dropdown, query); + const inputs = await screen.findAllByLabelText('Selected instance type'); + expect(inputs.length).toBe(1); + expect(inputs[0]).toBeInTheDocument(); + }); }); });