chore: update project command scripts

This commit is contained in:
Ayo 2022-10-04 14:30:00 +02:00
parent 509cece7d5
commit d2a9c77724
7 changed files with 22 additions and 16 deletions

View file

@ -57,7 +57,7 @@ npm i
4. Run the demo application 4. Run the demo application
``` ```
npm run dev npm start
``` ```
5. Open the demo application on you browser. Browse to the address: 5. Open the demo application on you browser. Browse to the address:
@ -69,11 +69,8 @@ https://localhost:3000
# Running package tests # Running package tests
Please run the tests before creating a PR to make sure nothing is broken. Please run the tests before creating a PR to make sure nothing is broken.
Since we only have one package for now, this is the command to run:
``` ```
npm run test -w astro-reactive-form npm test
``` ```
# Hacking with the packages # Hacking with the packages

View file

@ -49,7 +49,7 @@ npm i
4. Run the demo application 4. Run the demo application
``` ```
npm run dev npm start
``` ```
5. Open the demo application on you browser. Browse to the address: 5. Open the demo application on you browser. Browse to the address:
@ -58,6 +58,12 @@ npm run dev
https://localhost:3000 https://localhost:3000
``` ```
6. To run the tests:
```
npm test
```
_[Please report issues and suggestions](https://github.com/ayoayco/astro-reactive-library/issues)_ _[Please report issues and suggestions](https://github.com/ayoayco/astro-reactive-library/issues)_
# Contributors # Contributors

View file

@ -3,4 +3,4 @@
To start the app: To start the app:
1. `npm i` 1. `npm i`
1. `npm run dev` 1. `npm start`

View file

@ -14,6 +14,8 @@
".": "./index.ts" ".": "./index.ts"
}, },
"scripts": { "scripts": {
"start": "npm run dev -w demo",
"test": "npm run test --workspaces --if-present",
"dev": "npm run dev -w demo", "dev": "npm run dev -w demo",
"bump-patch": "npm version patch -w", "bump-patch": "npm version patch -w",
"bump-minor": "npm version minor -w", "bump-minor": "npm version minor -w",

View file

@ -15,7 +15,7 @@ const { formGroups } = Astro.props;
<style> <style>
.light { .light {
/** /**
* run dev server with: "npm run dev", * run dev server with: "npm start",
* then open browser to "localhost:3000" * then open browser to "localhost:3000"
* add a class="light" to the <form> element above to test changes * add a class="light" to the <form> element above to test changes
* INSERT STYLES FOR LIGHT MODE BELOW: */ * INSERT STYLES FOR LIGHT MODE BELOW: */
@ -23,7 +23,7 @@ const { formGroups } = Astro.props;
.dark { .dark {
/** /**
* run dev server with: "npm run dev", * run dev server with: "npm start",
* then open browser to "localhost:3000" * then open browser to "localhost:3000"
* add a class="dark" to the <form> element above to test changes * add a class="dark" to the <form> element above to test changes
* INSERT STYLES FOR DARK MODE BELOW: */ * INSERT STYLES FOR DARK MODE BELOW: */

View file

@ -11,28 +11,32 @@ describe('Form.astro test', () => {
describe('INPUT: formGroups', () => { describe('INPUT: formGroups', () => {
it('Should handle undefined formGroups prop', async () => { it('Should handle undefined formGroups prop', async () => {
// arrange // arrange
const expectedResult = '<form></form>' const expectedCount = 0;
const element = /<fieldset>/g;
const props = { formGroups: undefined }; const props = { formGroups: undefined };
component = await getComponentOutput('./Form.astro', props); component = await getComponentOutput('./Form.astro', props);
// act // act
const actualResult = cleanString(component.html); const actualResult = cleanString(component.html);
const matches = actualResult.match(element) || [];
// assert // assert
expect(actualResult).to.contain(expectedResult); expect(matches.length).to.equal(expectedCount);
}); });
it('Should handle empty formGroups prop', async () => { it('Should handle empty formGroups prop', async () => {
// arrange // arrange
const expectedResult = '<form></form>' const expectedCount = 0;
const element = /<fieldset>/g;
const props = { formGroups: [] }; const props = { formGroups: [] };
component = await getComponentOutput('./Form.astro', props); component = await getComponentOutput('./Form.astro', props);
// act // act
const actualResult = cleanString(component.html); const actualResult = cleanString(component.html);
const matches = actualResult.match(element) || [];
// assert // assert
expect(actualResult).to.contain(expectedResult); expect(matches.length).to.equal(expectedCount);
}); });
it('Should render a fieldset for each form group', async () => { it('Should render a fieldset for each form group', async () => {

View file

@ -9,9 +9,6 @@
}, },
"main": "index.js", "main": "index.js",
"devDependencies": {}, "devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/ayoayco/astro-reactive-library.git" "url": "git+https://github.com/ayoayco/astro-reactive-library.git"