Skip to content

Commit d3ac4c9

Browse files
committed
test: add tests
1 parent c594482 commit d3ac4c9

File tree

1 file changed

+57
-24
lines changed

1 file changed

+57
-24
lines changed

packages/compass-data-modeling/src/components/saved-diagrams-list.spec.tsx

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,23 @@ const storageItems: MongoDBDataModelDescription[] = [
2121
{
2222
id: '2',
2323
name: 'Two',
24-
edits: [],
24+
edits: [
25+
{
26+
type: 'SetModel',
27+
model: {
28+
collections: [
29+
{
30+
ns: 'db2.collection2',
31+
indexes: [],
32+
displayPosition: [0, 0],
33+
shardKey: {},
34+
jsonSchema: { bsonType: 'object' },
35+
},
36+
],
37+
relationships: [],
38+
},
39+
},
40+
],
2541
connectionId: null,
2642
},
2743
{
@@ -126,33 +142,50 @@ describe('SavedDiagramsList', function () {
126142
expect(store.getState().generateDiagramWizard.inProgress).to.be.true;
127143
});
128144

129-
it('filters the list of diagrams', async function () {
130-
const searchInput = screen.getByPlaceholderText('Search');
131-
userEvent.type(searchInput, 'One');
132-
await waitFor(() => {
133-
expect(screen.queryByText('One')).to.exist;
145+
describe('search', function () {
146+
it('filters the list of diagrams by name', async function () {
147+
const searchInput = screen.getByPlaceholderText('Search');
148+
userEvent.type(searchInput, 'One');
149+
await waitFor(() => {
150+
expect(screen.queryByText('One')).to.exist;
151+
});
152+
153+
await waitFor(() => {
154+
expect(screen.queryByText('Two')).to.not.exist;
155+
expect(screen.queryByText('Three')).to.not.exist;
156+
});
134157
});
135158

136-
await waitFor(() => {
137-
expect(screen.queryByText('Two')).to.not.exist;
138-
expect(screen.queryByText('Three')).to.not.exist;
159+
it('filters the list of diagrams by database', async function () {
160+
const searchInput = screen.getByPlaceholderText('Search');
161+
userEvent.type(searchInput, 'db2');
162+
await waitFor(() => {
163+
expect(screen.queryByText('Two')).to.exist;
164+
});
165+
166+
await waitFor(() => {
167+
expect(screen.queryByText('One')).to.not.exist;
168+
expect(screen.queryByText('Three')).to.not.exist;
169+
});
139170
});
140-
});
141171

142-
it('shows empty content when filter for a non-existent diagram', async function () {
143-
const searchInput = screen.getByPlaceholderText('Search');
144-
userEvent.type(searchInput, 'Hello');
145-
await waitFor(() => {
146-
expect(screen.queryByText('No results found.')).to.exist;
147-
expect(
148-
screen.queryByText("We can't find any diagram matching your search.")
149-
).to.exist;
150-
});
151-
152-
await waitFor(() => {
153-
expect(screen.queryByText('One')).to.not.exist;
154-
expect(screen.queryByText('Two')).to.not.exist;
155-
expect(screen.queryByText('Three')).to.not.exist;
172+
it('shows empty content when filter for a non-existent diagram', async function () {
173+
const searchInput = screen.getByPlaceholderText('Search');
174+
userEvent.type(searchInput, 'Hello');
175+
await waitFor(() => {
176+
expect(screen.queryByText('No results found.')).to.exist;
177+
expect(
178+
screen.queryByText(
179+
"We can't find any diagram matching your search."
180+
)
181+
).to.exist;
182+
});
183+
184+
await waitFor(() => {
185+
expect(screen.queryByText('One')).to.not.exist;
186+
expect(screen.queryByText('Two')).to.not.exist;
187+
expect(screen.queryByText('Three')).to.not.exist;
188+
});
156189
});
157190
});
158191
});

0 commit comments

Comments
 (0)