Skip to content

Commit 151ee51

Browse files
committed
Github actions CI workflow
1 parent f8b5719 commit 151ee51

File tree

6 files changed

+76
-22
lines changed

6 files changed

+76
-22
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: ngx-json-treeview CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build_and_test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: pnpm/action-setup@v3
17+
- name: Set up node v20
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 20.x
21+
cache: 'pnpm'
22+
- name: Install dependencies
23+
run: pnpm install
24+
- name: Check Code Format
25+
run: pnpm format:check
26+
- name: Build
27+
run: pnpm build
28+
- name: Run Tests
29+
run: pnpm test --watch=false

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"private": true,
1919
"dependencies": {
2020
"@angular/animations": "^19.2.6",
21+
"@angular/cdk": "^19.2.9",
2122
"@angular/common": "^19.2.6",
2223
"@angular/compiler": "^19.2.6",
2324
"@angular/core": "^19.2.6",

pnpm-lock.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/demo/src/app/app.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { Component } from '@angular/core';
22
import { NgxJsonTreeviewComponent } from 'ngx-json-treeview';
33

44
@Component({
5-
selector: 'app-root',
6-
imports: [NgxJsonTreeviewComponent],
7-
templateUrl: './app.component.html',
8-
styleUrl: './app.component.scss'
5+
selector: 'app-root',
6+
imports: [NgxJsonTreeviewComponent],
7+
templateUrl: './app.component.html',
8+
styleUrl: './app.component.scss',
99
})
1010
export class AppComponent {
1111
baseObj = {
Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
1+
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
2+
import { TestBed } from '@angular/core/testing';
33
import { NgxJsonTreeviewComponent } from './ngx-json-treeview.component';
44

5-
describe('NgxJsonTreeviewComponent', () => {
6-
let component: NgxJsonTreeviewComponent;
7-
let fixture: ComponentFixture<NgxJsonTreeviewComponent>;
5+
async function setupTest({
6+
json = {},
7+
}: {
8+
json?: any;
9+
} = {}) {
10+
await TestBed.configureTestingModule({
11+
imports: [NgxJsonTreeviewComponent],
12+
}).compileComponents();
813

9-
beforeEach(async () => {
10-
await TestBed.configureTestingModule({
11-
imports: [NgxJsonTreeviewComponent],
12-
}).compileComponents();
14+
const fixture = TestBed.createComponent(NgxJsonTreeviewComponent);
15+
const component = fixture.componentInstance;
16+
fixture.componentRef.setInput('json', json);
17+
fixture.detectChanges();
18+
const loader = TestbedHarnessEnvironment.loader(fixture);
1319

14-
fixture = TestBed.createComponent(NgxJsonTreeviewComponent);
15-
component = fixture.componentInstance;
16-
fixture.detectChanges();
17-
});
20+
return { component, fixture, loader };
21+
}
1822

19-
it('should create', () => {
23+
describe('NgxJsonTreeviewComponent', () => {
24+
it('should create', async () => {
25+
const { component } = await setupTest();
2026
expect(component).toBeTruthy();
2127
});
2228
});

projects/ngx-json-treeview/src/lib/ngx-json-treeview.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ export interface Segment {
1010
}
1111

1212
@Component({
13-
selector: 'ngx-json-treeview',
14-
imports: [CommonModule],
15-
templateUrl: './ngx-json-treeview.component.html',
16-
styleUrls: ['./ngx-json-treeview.component.scss']
13+
selector: 'ngx-json-treeview',
14+
imports: [CommonModule],
15+
templateUrl: './ngx-json-treeview.component.html',
16+
styleUrls: ['./ngx-json-treeview.component.scss'],
1717
})
1818
export class NgxJsonTreeviewComponent {
1919
// inputs & outputs

0 commit comments

Comments
 (0)