Skip to content

Commit

Permalink
feat(typescript): convert to typescript
Browse files Browse the repository at this point in the history
update tests to tsx

match types version with dep versions
  • Loading branch information
xAndreiLi committed Nov 8, 2024
1 parent 95702fd commit 00aec0e
Show file tree
Hide file tree
Showing 10 changed files with 9,376 additions and 8,101 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"presets": [
"amex"
"amex",
"@babel/preset-typescript"
]
}
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "amex"
"extends": "amex",
"ignorePatterns": ["build/**/*"]
}
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Release
env:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
test-results
.jest-cache
.jest-cache
build
File renamed without changes.
10 changes: 5 additions & 5 deletions __tests__/index.spec.jsx → __tests__/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ describe('createSharedContext', () => {
it('should create context with React.createContext', () => {
const createContextSpy = jest.spyOn(React, 'createContext');
// eslint-disable-next-line unicorn/import-index, global-require
const createSharedContext = require('../index.js');
const createSharedContext = require('../src/index.ts');
createSharedContext('myCoolDefaultValue', 'sharedContext');

expect(createContextSpy).toHaveBeenCalledWith('myCoolDefaultValue');
});

it('should return the same context object if the key matches', () => {
// eslint-disable-next-line unicorn/import-index, global-require
const createSharedContext = require('../index.js');
const createSharedContext = require('../src/index.ts');
const testProvider = createSharedContext('', 'sharedContext');
const { Provider } = testProvider;
const testConsumer = createSharedContext('', 'sharedContext');
Expand All @@ -54,7 +54,7 @@ describe('createSharedContext', () => {

it('should not return the same context object if the key does not matches', () => {
// eslint-disable-next-line unicorn/import-index, global-require
const createSharedContext = require('../index.js');
const createSharedContext = require('../src/index.ts');
const defaultValue = 'default';
const testProvider = createSharedContext('', 'sharedContext');
const { Provider } = testProvider;
Expand All @@ -81,7 +81,7 @@ describe('createSharedContext', () => {

it('should use the same default value from first call', () => {
// eslint-disable-next-line unicorn/import-index, global-require
const createSharedContext = require('../index.js');
const createSharedContext = require('../src/index.ts');
const defaultValue = 'default';
createSharedContext(defaultValue, 'someContext');
const testDefaultContext = createSharedContext('never see this', 'someContext');
Expand All @@ -106,7 +106,7 @@ describe('createSharedContext', () => {
const createContextSpy = jest.spyOn(React, 'createContext');
const warnSpy = jest.spyOn(console, 'warn');
// eslint-disable-next-line unicorn/import-index, global-require
const createSharedContext = require('../index.js');
const createSharedContext = require('../src/index.ts');

createSharedContext('default');
expect(warnSpy).toHaveBeenCalledWith('Second parameter in createSharedReactContext was not set, defaulting to React.createContext');
Expand Down
Loading

0 comments on commit 00aec0e

Please sign in to comment.