@@ -3,10 +3,18 @@ import { test } from "node:test";
33import { join } from "path" ;
44
55import { getSelectedOption } from "./lib" ;
6- import type { Options , SelectedOption } from "./types" ;
6+ import {
7+ Framework ,
8+ TemplateType ,
9+ type Options ,
10+ type SelectedOption ,
11+ } from "./types" ;
712
813test ( "getSelectedOption(angular, minimal)" , ( ) => {
9- const opts : Options = { framework : "angular" , template : "minimal" } ;
14+ const opts : Options = {
15+ framework : Framework . Angular ,
16+ template : TemplateType . Minimal ,
17+ } ;
1018 const result : SelectedOption = getSelectedOption ( opts ) ;
1119
1220 const expectedName : string = "web3js-angular-dapp-min" ;
@@ -30,8 +38,29 @@ test("getSelectedOption(angular, minimal)", () => {
3038 ) ;
3139} ) ;
3240
41+ test ( "getSelectedOption(angular, demonstration)" , ( ) => {
42+ const opts : Options = {
43+ framework : Framework . Angular ,
44+ template : TemplateType . Demonstration ,
45+ } ;
46+ try {
47+ const result : SelectedOption = getSelectedOption ( opts ) ;
48+ } catch ( e ) {
49+ assert . strictEqual (
50+ e . toString ( ) ,
51+ "Error: Angular demonstration dApp has not yet been implemented." ,
52+ ) ;
53+ return ;
54+ }
55+
56+ assert . strictEqual ( true , false ) ;
57+ } ) ;
58+
3359test ( "getSelectedOption(react, minimal)" , ( ) => {
34- const opts : Options = { framework : "react" , template : "minimal" } ;
60+ const opts : Options = {
61+ framework : Framework . React ,
62+ template : TemplateType . Minimal ,
63+ } ;
3564 const result : SelectedOption = getSelectedOption ( opts ) ;
3665
3766 const expectedName : string = "web3js-react-dapp-min" ;
@@ -54,3 +83,31 @@ test("getSelectedOption(react, minimal)", () => {
5483 "unexpected project location" ,
5584 ) ;
5685} ) ;
86+
87+ test ( "getSelectedOption(react, demonstration)" , ( ) => {
88+ const opts : Options = {
89+ framework : Framework . React ,
90+ template : TemplateType . Demonstration ,
91+ } ;
92+ const result : SelectedOption = getSelectedOption ( opts ) ;
93+
94+ const expectedName : string = "web3js-react-dapp-demo" ;
95+ assert . strictEqual (
96+ result . projectName ,
97+ expectedName ,
98+ "unexpected project name" ,
99+ ) ;
100+
101+ const expectedLocation : string = join (
102+ __dirname ,
103+ ".." ,
104+ "templates" ,
105+ "demo" ,
106+ expectedName ,
107+ ) ;
108+ assert . strictEqual (
109+ result . projectLocation ,
110+ expectedLocation ,
111+ "unexpected project location" ,
112+ ) ;
113+ } ) ;
0 commit comments