From 7557f5cfe63be45411f4d3197914fda4346d66ca Mon Sep 17 00:00:00 2001 From: Florian Rappl Date: Fri, 15 Dec 2023 11:58:02 +0100 Subject: [PATCH] Added new tests --- LICENSE | 2 +- README.md | 10 +++++++--- src/pilet-build.test.ts | 44 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/LICENSE b/LICENSE index 45c7a95..7f4e972 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 - 2023 smapiot +Copyright (c) 2019 - 2024 smapiot Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index ab98292..f741c4d 100644 --- a/README.md +++ b/README.md @@ -108,9 +108,11 @@ If you don't specify the bundler name then the current working directory's *pack - ✅ Scaffold pilet (using `sample-piral`) - ✅ Run/debug new pilet -- ✅ Build v2 pilet -- ✅ Build v1 pilet -- ✅ Build v0 pilet +- ✅ Build `mf` pilet +- ✅ Build `v3` pilet +- ✅ Build `v2` pilet +- ✅ Build `v1` pilet +- ✅ Build `v0` pilet - ✅ Build standalone pilet - ✅ Build pilet manifest file - ✅ Publish pilet (to temp. feed) @@ -142,6 +144,8 @@ Available features: - `pilet.v0`, supports the `v0` schema - `pilet.v1`, supports the `v1` schema - `pilet.v2`, supports the `v2` schema +- `pilet.v3`, supports the `v3` schema +- `pilet.mf`, supports the `mf` schema - `importmap.ref`, supports usage of an importmap - `importmap.local`, supports local creation of importmap side-bundles - `build.pilet`, supports building a pilet diff --git a/src/pilet-build.test.ts b/src/pilet-build.test.ts index 5946481..74dda21 100644 --- a/src/pilet-build.test.ts +++ b/src/pilet-build.test.ts @@ -7,12 +7,52 @@ runTests('pilet-build', ({ test, setup }) => { await ctx.run(`npm i emojis-list@3.0.0`); }); + test( + 'from-sample-piral-directly-mf', + 'can build a standard templated mf pilet from sample-piral', + ['pilet.mf', 'build.pilet'], + async (ctx) => { + await ctx.run(`npx pilet build --schema mf`); + + await ctx.assertFiles({ + 'dist/index.js'(content: string) { + expect(content).not.toBe(''); + expect(content).not.toContain('//@pilet'); + expect(content).not.toContain('System.register('); + expect(content).toMatch(/^var\s/); + expect(content).toContain('./pilet'); + }, + }); + }, + ); + + test( + 'from-sample-piral-directly-v3', + 'can build a standard templated v3 pilet from sample-piral', + ['pilet.v3', 'build.pilet'], + async (ctx) => { + await ctx.run(`npx pilet build --schema v3`); + + await ctx.assertFiles({ + 'dist/index.js'(content: string) { + expect(content).not.toBe(''); + expect(content).toContain('//@pilet v:3'); + expect(content).toContain('System.register('); + expect(content).not.toContain('currentScript.app='); + expect(content).not.toContain('require("react")'); + expect(content).toContain('styles:'); + expect(content).not.toContain('stylesheet'); + }, + }); + }, + ); + test( 'from-sample-piral-directly-v2', 'can build a standard templated v2 pilet from sample-piral', ['pilet.v2', 'build.pilet'], async (ctx) => { - await ctx.run(`npx pilet build`); + await ctx.run(`npx pilet build --schema v2`); await ctx.assertFiles({ 'dist/index.js'(content: string) { @@ -21,6 +61,8 @@ runTests('pilet-build', ({ test, setup }) => { expect(content).toContain('System.register('); expect(content).not.toContain('currentScript.app='); expect(content).not.toContain('require("react")'); + expect(content).toContain('stylesheet'); + expect(content).not.toContain('styles:'); }, }); },