Skip to content

Commit

Permalink
chore: update readme, add test for theme
Browse files Browse the repository at this point in the history
  • Loading branch information
webdiscus committed Aug 10, 2024
1 parent 4e6e164 commit a14e2cb
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ about: Create a report to help us improve
## Additional context

<!-- Add any other context about the problem here. -->

## Appreciation for the useful project

- [ ] After the problem is resolved, do not forget to give a star ⭐
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/Feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ about: Suggest an idea for this project

**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

## Appreciation for the useful project

- [ ] After the feature is implemented, do not forget to give a star ⭐
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/Other.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ about: Something else
---

<!-- Bug reports and Feature requests must use other templates, or will be closed -->

## Appreciation for the useful project

- [ ] Do not forget to give a star ⭐
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ This PR contains a:
- [ ] I have read the **CONTRIBUTING** document.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

## Appreciation for the useful project

- [ ] Do not forget to give a star ⭐
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,15 +536,15 @@ Define your own themes:
import ansis from 'ansis';

const theme = {
error: ansis.red.bold,
info: ansis.cyan.italic,
warning: ansis.black.bgYellowBright,
warn: ansis.black.bgYellowBright,
error: ansis.red.bold,
ruby: ansis.hex('#E0115F'),
};

theme.error('error');
theme.info('info');
theme.warning('warning');
theme.warn('warning');
theme.error('error');
theme.ruby('Ruby color');
```

Expand Down
27 changes: 27 additions & 0 deletions test/functional.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,4 +455,31 @@ describe('base ANSI 16 colors', () => {
const expected = '\x1b[107mfoo\x1b[49m';
expect(esc(received)).toEqual(esc(expected));
});
});

describe('custom theme', () => {
// define theme
const theme = {
info: ansis.green,
warn: ansis.yellow,
error: ansis.red,
};

test(`theme.info('info')`, () => {
const received = theme.info('info');
const expected = '\x1b[32minfo\x1b[39m';
expect(esc(received)).toEqual(esc(expected));
});

test(`theme.warn('warn')`, () => {
const received = theme.warn('warn');
const expected = '\x1b[33mwarn\x1b[39m';
expect(esc(received)).toEqual(esc(expected));
});

test(`theme.error('error')`, () => {
const received = theme.error('error');
const expected = '\x1b[31merror\x1b[39m';
expect(esc(received)).toEqual(esc(expected));
});
});

0 comments on commit a14e2cb

Please sign in to comment.