Skip to content

Commit feb25af

Browse files
committed
chore: tests
1 parent 6fe639b commit feb25af

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

src/notebooks/deepnote/deepnoteTreeDataProvider.unit.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,26 @@ suite('DeepnoteTreeDataProvider', () => {
8585
assert.isArray(children);
8686
});
8787

88+
test('should return loading item on initial call', async () => {
89+
const newProvider = new DeepnoteTreeDataProvider();
90+
91+
const children = await newProvider.getChildren();
92+
assert.isArray(children);
93+
94+
if (children.length > 0) {
95+
// If there are children, check if the first one is a loading item
96+
const firstChild = children[0];
97+
if (firstChild.type === DeepnoteTreeItemType.Loading) {
98+
assert.strictEqual(firstChild.type, DeepnoteTreeItemType.Loading);
99+
assert.strictEqual(firstChild.contextValue, 'loading');
100+
}
101+
}
102+
103+
if (newProvider && typeof newProvider.dispose === 'function') {
104+
newProvider.dispose();
105+
}
106+
});
107+
88108
test('should return array when called with project item parent', async () => {
89109
// Create a mock project item
90110
const mockProjectItem = new DeepnoteTreeItem(
@@ -130,6 +150,19 @@ suite('DeepnoteTreeDataProvider', () => {
130150
// Call refresh to verify it doesn't throw
131151
assert.doesNotThrow(() => provider.refresh());
132152
});
153+
154+
test('should reset initial scan state on refresh', async () => {
155+
// First call to getChildren to trigger initial scan
156+
const firstChildren = await provider.getChildren();
157+
assert.isArray(firstChildren);
158+
159+
// Call refresh to reset state
160+
provider.refresh();
161+
162+
// After refresh, getChildren should show loading state again
163+
const childrenAfterRefresh = await provider.getChildren();
164+
assert.isArray(childrenAfterRefresh);
165+
});
133166
});
134167

135168
suite('data management', () => {

src/notebooks/deepnote/deepnoteTreeItem.unit.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,46 @@ suite('DeepnoteTreeItem', () => {
579579
});
580580
});
581581

582+
suite('Loading type', () => {
583+
test('should create loading item with null data', () => {
584+
const context: DeepnoteTreeItemContext = {
585+
filePath: '',
586+
projectId: ''
587+
};
588+
589+
const item = new DeepnoteTreeItem(
590+
DeepnoteTreeItemType.Loading,
591+
context,
592+
null,
593+
TreeItemCollapsibleState.None
594+
);
595+
596+
assert.strictEqual(item.type, DeepnoteTreeItemType.Loading);
597+
assert.strictEqual(item.contextValue, 'loading');
598+
assert.strictEqual(item.collapsibleState, TreeItemCollapsibleState.None);
599+
assert.isNull(item.data);
600+
});
601+
602+
test('should skip initialization for loading items', () => {
603+
const context: DeepnoteTreeItemContext = {
604+
filePath: '',
605+
projectId: ''
606+
};
607+
608+
const item = new DeepnoteTreeItem(
609+
DeepnoteTreeItemType.Loading,
610+
context,
611+
null,
612+
TreeItemCollapsibleState.None
613+
);
614+
615+
// Loading items can have label and iconPath set manually after creation
616+
// but should not throw during construction
617+
assert.isDefined(item);
618+
assert.strictEqual(item.type, DeepnoteTreeItemType.Loading);
619+
});
620+
});
621+
582622
suite('integration scenarios', () => {
583623
test('should create valid tree structure hierarchy', () => {
584624
// Create parent project file

0 commit comments

Comments
 (0)