This repository has been archived by the owner on Mar 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,132 additions
and
5,329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
/dist | ||
/tmp | ||
/out-tsc | ||
/projects/hot-table/package.json | ||
|
||
# dependencies | ||
/node_modules | ||
|
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
projects/hot-table/src/lib/hot-table-registerer.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
import { Component } from '@angular/core'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import Handsontable from 'handsontable'; | ||
import { HotTableModule, HotTableRegisterer } from '@handsontable/angular'; | ||
|
||
@Component({ | ||
selector: 'hot-test-component', | ||
template: '' | ||
}) | ||
class TestComponent { | ||
public prop: object = {}; | ||
id = 'hot'; | ||
|
||
constructor (private _registerer: HotTableRegisterer) { } | ||
|
||
getHotInstance(instance: string): Handsontable { | ||
return this._registerer.getInstance(instance); | ||
} | ||
} | ||
|
||
describe('HotTableComponent', () => { | ||
let fixture: ComponentFixture<TestComponent>; | ||
|
||
beforeEach((() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ TestComponent ], | ||
imports: [ HotTableModule.forRoot() ], | ||
}); | ||
})); | ||
|
||
afterEach(() => { | ||
TestBed.resetTestingModule(); | ||
}); | ||
|
||
it(`should register instance if component has hotId attribute`, async() => { | ||
TestBed.overrideComponent(TestComponent, { | ||
set: { | ||
template: `<hot-table [hotId]="id"></hot-table>` | ||
} | ||
}); | ||
await TestBed.compileComponents().then(() => { | ||
fixture = TestBed.createComponent(TestComponent); | ||
const app = fixture.componentInstance; | ||
|
||
fixture.detectChanges(); | ||
|
||
expect(app.getHotInstance(app.id)).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
it(`should register every hot-table component with added hotID attribute`, async() => { | ||
TestBed.overrideComponent(TestComponent, { | ||
set: { | ||
template: ` | ||
<hot-table [hotId]="prop.hotTableId"></hot-table> | ||
<hot-table [hotId]="'hot1'"></hot-table> | ||
<hot-table hotId="hot2"></hot-table> | ||
` | ||
} | ||
}); | ||
await TestBed.compileComponents().then(() => { | ||
fixture = TestBed.createComponent(TestComponent); | ||
const app = fixture.componentInstance; | ||
|
||
app.prop['hotTableId'] = 'hot'; | ||
|
||
fixture.detectChanges(); | ||
|
||
expect(app.getHotInstance(app.prop['hotTableId'])).toBeDefined(); | ||
expect(app.getHotInstance('hot1')).toBeDefined(); | ||
expect(app.getHotInstance('hot2')).toBeDefined(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.